Strings problem, implementation. Codeforces