Problem B, codeforces round 216