Codeforces: Petya and steps (another version)