while True:
  n = int(input())
  if n == 0:
    break
  
  if n % 17 == 0:
    print("1")
  else:
    print("0")
while True:
  n = int(input())
  if n == 0:
    break
  
  if n % 17 == 0:
    print("1")
  else:
    print("0")