import sequtils, strutils, sugar

const
  inf = "INF"


proc isKadomatsu(xs: seq[int]): bool =
  let
    x = xs[0]
    y = xs[1]
    z = xs[2]
  if x == z: return false
  if x < y and y > z: return true
  if x > y and y < z: return true
  false


let
  a = stdin.readLine.split.map parseInt

if a.isKadomatsu:
  echo inf
  quit()

let
  list = newSeq.collect:
    for i in 3 .. a.max:
      if a.mapIt(it mod i).isKadomatsu: i

echo list.len