import java.util.Scanner object Problem197 { def proc(before: String, n: Int, after: String): String = { val beforeCoins: Int = before.filter(_ == 'o').length val afterCoins: Int = after.filter(_ == 'o').length beforeCoins match { case _ if beforeCoins != afterCoins => "SUCCESS" case _ if n == 0 && before != after => "SUCCESS" case 3 => "FAILURE" case 2 => f(before.indexOf("x"), after.indexOf("x"), n) case 1 => f(before.indexOf("o"), after.indexOf("o"), n) case 0 => "FAILURE" } } def f(beforePlace: Int, afterPlace: Int, n: Int): String = { if (beforePlace + afterPlace == 2 && n == 1) "SUCCESS" else "FAILURE" } def main(args: Array[String]) { val sc = new Scanner(System.in) val before = sc.next() val n = sc.nextInt() val after = sc.next() val result = proc(before, n, after) println(result) } }