Implemented counting solution