sb = raw_input() N = input() sa = raw_input() bc = sb.count("o") ac = sa.count("o") if bc != ac: print "SUCCESS" elif bc == 0 or bc == 3: print "FAILURE" else: m = "o" if bc == 1 else "x" bi = sb.index(m) ai = sa.index(m) print "SUCCESS" if (N==0 and ai!=bi) or (N==1 and (ai==bi==1 or abs(ai-bi)==2)) else "FAILURE"