Problem:

Age Difference
 

A trick of fate caused Hatsumi and Taku to come to know each other. To keep the encounter in memory, they decided to calculate the difference between their ages. But the difference in ages varies depending on the day it is calculated. While trying again and again, they came to notice that the difference of their ages will hit a maximum value even though the months move on forever.

  Given the birthdays for the two, make a program to report the maximum difference between their ages. The age increases by one at the moment the birthday begins. If the birthday coincides with the 29th of February in a leap year, the age increases at the moment the 1st of March arrives in non-leap years.

Input

  The input is given in the following format.

y_1 m_1 d_1
y_2 m_2 d_2

The first and second lines provide Hatsumi’s and Taku’s birthdays respectively in year y_i (1 ≤ y_i ≤ 3000), month m_i (1 ≤ m_i ≤ 12), and day d_i (1 ≤ d_i ≤ Dmax) format. Where Dmax is given as follows:

  

 28 when February in a non-leap year

 29 when February in a leap-year

 30 in April, June, September, and November

 31 otherwise.

  It is a leap year if the year represented as a four-digit number is divisible by 4. Note, however, that it is a non-leap year if divisible by 100, and a leap year if divisible by 400.

Output

  Output the maximum difference between their ages.

Sample Input 1

1999 9 9
2001 11 3

Sample Output 1

3

  In this example, the difference of ages between them in 2002 and subsequent years is 3 on the 1st of October, but 2 on the 1st of December.

Sample Input 2

2008 2 29
2015 3 1

Sample Output 2

8

In this example, the difference of ages will become 8 on the 29th of February in and later years than 2016.



Sample input:
1999 9 9
2001 11 3


Sample output:
3

Submission status: Accepted

Solution code:
a = sorted([tuple(map(int,input().split())) for _ in [0,0]])
print(a[1][0] - a[0][0] + (1 if a[1][1] > a[0][1] or (a[1][1] == a[0][1] and a[1][2] > a[0][2]) else 0))

Submission status: Accepted

Solution code:
y1,m1,d1 = map(int, input().split())
y2,m2,d2 = map(int, input().split())

if y1 > y2 or (y1 == y2 and (m1 > m2 or ( m1 == m2 and d1 > d2 ))):
    y1, y2 = y2, y1
    m1, m2 = m2, m1
    d1, d2 = d2, d1

if m1 < m2 or (m1 == m2 and d1 < d2): print(y2 - y1 + 1)
else: print(y2 - y1)

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
d,e,f = map(int,input().split())
if b == e and c == f:
  print(abs(a-d))
  exit()
if a > d:
  num = 100 * b + c
  nu = 100 * e + f
elif a < d:
  num = 100 * e + f
  nu = 100 * b + c
else:
  print(1)
  exit()
if num > nu:
  print(abs(a-d)+1)
else:
  print(abs(a-d))