class Yukicoder def initialize s1 = gets.chomp.chars n = gets.to_i s2 = gets.chomp.chars success = true success &= s1.sort == s2.sort if success o_diff = (s1.index('o') - s2.index('o')).abs x_diff = (s1.index('x') - s1.index('x')).abs diff = [o_diff, x_diff].max success &= diff <= n end if success puts "FAILURE" else puts "SUCCESS" end end end Yukicoder.new