from sys import stdin, exit

def die(msg):
  print msg
  exit(1)

def add(x,y): # simulates addition in 32-bit integers
  result = (x+y) % (2**32)
  if result >= 2**31: result -= 2**32
  return result

def speedup(x): # reasonably fast primality testing
  if x<=1: return True
  y = 2
  while True:
    if y*y > x: return True
    if x % y == 0: return False
    y += 1

data = stdin.read().split()

try: where = int(data[0])
except: die('The first token is not a 32-bit int.')
if (where < - 2**31) or (where >= 2**31): die('The first token is not a 32-bit int.')

try: step = int(data[1])
except: die('The second token is not a 32-bit int.')
if (step < - 2**31) or (step >= 2**31): die('The first token is not a 32-bit int.')

if step % (2**29) != 0: die('The cycle is not infinite.')
if step == 0: die('The cycle is not infinite.')

seen = set()
best = where
stars = 0

while True:
  where = add(where,step)
  if where < best:
    best = where
    stars += 1
  if where in seen:
    if stars < 3: die('Too few stars.') # comment out this line to get a tester for R1 :)
    print "OK"
    exit(0)
  seen.add(where)
  if not speedup(where): die('The cycle is not infinite.')


