output_description: If the date 2019-M_1-D_1 is the last day of a month, print `1`; otherwise,
  print `0`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      M_1 D_1
      M_2 D_2
attempt: def is_cross(la, lb, x1, x2):
      ya1 = la[0] * x1 + la[1]
      ya2 = la[0] * x2 + la[1]
      yb1 = lb[0] * x1 + lb[1]
      yb2 = lb[0] * x2 + lb[1]
      if ya1 == yb1:
          return False
      return (ya1 - yb1) * (ya2 - yb2) <= 0
  
  
  def get_line(c, x, y):
      return [c, y - c * x]
  
  
  t = list(map(int, input().split()))
  a = list(map(int, input().split()))
  b = list(map(int, input().split()))
  xa = sum([ti * ai for ti, ai in zip(t, a)])
  xb = sum([ti * bi for ti, bi in zip(t, b)])
  if xa / sum(t) == xb / sum(t):
      print("infinity")
  else:
      ans = 0
      t_pre = 0
      da = 0
      db = 0
      while True:
          ans_t = 0
          for ti, ai, bi in zip(t, a, b):
              t_post = t_pre + ti
              la = get_line(ai, t_pre, da)
              lb = get_line(bi, t_pre, db)
              ans_t += is_cross(la, lb, t_pre, t_post)
              t_pre = t_post
              da += ti * ai
              db += ti * bi
  
          if ans_t == 0:
              break
          ans += ans_t
      print(ans)
  
problem_description: Statement
  
  In this problem, a date is written as Y-M-D. For example, 2019-11-30 means
  November 30, 2019.
  
  Integers M_1, D_1, M_2, and D_2 will be given as input.  
  It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.  
  Determine whether the date 2019-M_1-D_1 is the last day of a month.
samples: [{"input": "11 16\n    11 17", "output": "0\n    \n\nNovember 16 is not the last day of a month.\n\n* * *"}, {"input": "11 30\n    12 1", "output": "1\n    \n\nNovember 30 is the last day of November."}]