from collections import deque S = input() memo = {} memo[S] = 0 Queue = deque() Queue.append((S, 0)) while Queue: x,cnt = Queue.popleft() y = x[1] + x[0] + x[2] if not y in memo: memo[y] = cnt + 1 Queue.append((y, cnt+1)) y = x[0] + x[2] + x[1] if not y in memo: memo[y] = cnt + 1 Queue.append((y, cnt+1)) N = int(input()) S = input() if not S in memo: print('SUCCESS') elif memo[S] <= N and memo[S] % 2 == N % 2: print('FAILURE') else: print('SUCCESS')