Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap years as follows:

 Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100; the centurial years that are exactly divisible by 400 are still leap years. For example, the year 1900 is not a leap year; the year 2000 is a leap year.  [Image] 

In this problem, you have been given two dates and your task is to calculate how many days are between them. Note, that leap years have unusual number of days in February.

Look at the sample to understand what borders are included in the aswer.


-----Input-----

The first two lines contain two dates, each date is in the format yyyy:mm:dd (1900 ≤ yyyy ≤ 2038 and yyyy:mm:dd is a legal date).


-----Output-----

Print a single integer — the answer to the problem.


-----Examples-----
Input
1900:01:01
2038:12:31

Output
50768

Input
1996:03:09
1991:11:12

Output
1579

Difficulty: interview

Starter code:

Solutions:
import datetime
from pprint import pprint
year, month, day = (int(i) for i in input().split(':'))
x = datetime.date(year, month, day)
year, month, day = (int(i) for i in input().split(':'))
y = datetime.date(year, month, day)
pprint(abs(int((x - y).days)))


from datetime import date

s1=list(map(int,input().split(':')))
s2=list(map(int,input().split(':')))
a = date(s1[0],s1[1],s1[2])
b = date(s2[0],s2[1],s2[2])
x=abs((a-b).days)
print(x)


import sys
import datetime

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

print(abs((datetime.date(y1, m1, d1) - datetime.date(y2, m2, d2)).days))


import datetime
a, b, c = list(map(int, input().split(':')))
d1 = datetime.date(a, b, c)
a, b, c = list(map(int, input().split(':')))
d2 = datetime.date(a, b, c)
d3 = abs(d2 - d1)
print(d3.days)


#!/usr/local/bin/python3.3 -tt

import datetime
import sys


def __starting_point():
    for l in sys.stdin:
        a = tuple(int(i) for i in l.strip().split(':'))
        s = datetime.date(*a)
        break

    for l in sys.stdin:
        a = tuple(int(i) for i in l.strip().split(':'))
        e = datetime.date(*a)
        break

    print(abs((e - s).days))

__starting_point()

start = input().split(":")
end = input().split(":")

start[0],start[1],start[2]=int(start[0]),int(start[1]),int(start[2])

end[0],end[1],end[2]=int(end[0]),int(end[1]),int(end[2])


if((start[0]>end[0]) or (start[0]==end[0] and start[1]>end[1]) or (start[0]==end[0] and start[1]==end[1] and start[2]>end[2])):
    e=list(start)
    s=list(end)
else:
    e=list(end)
    s=list(start)
days=0
for i in range(s[0]+1,e[0]):
    if(i%400==0):
        days+=366
    elif(i%100==0):
        days+=365
    elif(i%4==0):
        days+=366
    else:
        days+=365

month=[31,28,31,30,31,30,31,31,30,31,30,31]
if(s[0]%400==0):
    month[1]+=1
elif(s[0]%100==0):
    month[1]=28
elif(s[0]%4==0):
    month[1]+=1

for i in range(s[1]+1,13):
    days+=month[i-1]

month[1]=28

if(e[0]%400==0):
    month[1]+=1
elif(e[0]%100==0):
    month[1]=28
elif(e[0]%4==0):
    month[1]+=1

for i in range(0,e[1]-1):
    days+=month[i]
month[1]=28
if(s[0]%400==0):
    month[1]+=1
elif(s[0]%100==0):
    month[1]=28
elif(s[0]%4==0):
    month[1]+=1
days+=e[2]
days+=month[s[1]-1]-s[2]

if(s[0]==e[0]):
    days=0
    for i in range(s[1]+1,e[1]):
        days+=month[i-1]
    days+=e[2]
    days+=month[s[1]-1]-s[2]
if(s[0]==e[0] and s[2]==e[2]):

    days=0
    for i in range(s[1],e[1]):
        days+=month[i-1]
if(s[0]==e[0] and s[1]==e[1]):
    days=e[2]-s[2]
if(s[0]==e[0] and s[1]==e[1] and s[2]==e[2]):
    days=0

print(days)


from datetime import date

a1 = [int(i) for i in input().split(':')]
a2 = [int(i) for i in input().split(':')]

print(abs((date(a1[0], a1[1], a1[2]) - date(a2[0], a2[1], a2[2])).days))


from datetime import date,timedelta
import sys

def get_input ():
  return list(map (int,input().split(':')))

sy,sm,sd = get_input()
ey,em,ed = get_input()

#start = date (sy,sm,sd)
#end = date (ey,em,ed)

end = date (sy,sm,sd)
start = date (ey,em,ed)

print(abs((end-start).days))


3

month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def isn(yyyy):
    if yyyy == 1900:
        return False
    return yyyy % 4 == 0

def toint(date):
    yyyy, mm, dd = date
    res = 0
    for y in range(1900, yyyy):
        res += 365 + isn(y)
    for m in range(1, mm):
        res += month[m] + (m == 2 and isn(yyyy))
    return res + dd

first = tuple(map(int, input().strip().split(':')))
last = tuple(map(int, input().strip().split(':')))
if last < first:
    last, first = first, last
print(toint(last) - toint(first))


from datetime import date

d = [0] * 2

for i in range(0, 2):
    a = list(map(int, input().split(':')))
    d[i] = date(a[0], a[1], a[2])
    
r = (d[0] - d[1]).days

print(r if r >= 0 else -r)

from datetime import date
d1 = date(*map(int, input().split(':')))
d2 = date(*map(int, input().split(':')))
print(abs(d2 - d1).days)

from datetime import date
a = date(*list(map(int,input().split(':'))))
b = date(*list(map(int,input().split(':'))))
print(abs(a-b).days) 


def isLeep(year):
    if year % 400 == 0:
        return 1;
    else:
        if year % 4 == 0 and year % 100 != 0:
            return 1;
        return 0;
    
def cmp(y1, m1, d1, y2, m2, d2):
    if y1 > y2:
        return 0;
    else:
        if y1 == y2 and m1 > m2:
            return 0;
        else:
            if y1 == y2 and m1 == m2 and d1 > d2:
                return 0;
            return 1;

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

days = [31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

if cmp(y1, m1, d1, y2, m2, d2) == 0:
    t = y1; y1 = y2; y2 = t;
    t = m1; m1 = m2; m2 = t;
    t = d1; d1 = d2; d2 = t;

res = 0;
while True:
    res = res + 1;
    if y1 == y2 and m1 == m2 and d1 == d2:
        break;
    d1 = d1 + 1;
    if d1 <= days[m1]:
        continue;
    else:
        if d1 == 29:
            if isLeep(y1):
                continue;
            else:
                m1 = 3;
                d1 = 1;
        else:
            if d1 == 30:
                m1 = 3;
                d1 = 1;
            else:
                if d1 == 31:
                    m1 = m1 + 1;
                    d1 = 1;
                else:
                    if d1 == 32:
                        if m1 == 12:
                            y1 = y1 + 1;
                            m1 = 1;
                            d1 = 1;
                        else:
                            m1 = m1 + 1;
                            d1 = 1;

print(res - 1)
            



from datetime import *
R = lambda: datetime(*map(int, input().split(':')))
date1 = R()
date2 = R()
print(abs(date2 - date1).days)

#-------------------------------------------------------------------------------
# Name:        Codeforces
# Author:      Gogol2

#-------------------------------------------------------------------------------

m = [31,28,31,30,31,30,31,31,30,31,30,31]
def leap (yy):
    if ((yy % 400 == 0 or (yy % 4 == 0 and yy % 100) )):
        return 366
    else:
        return 365

def main():

    y1,m1,d1 = list(map(int,input().split(':')))
    y2,m2,d2 = list(map(int,input().split(':')))
    a = d1
    b = d2
    for i in range (0,y1):
        a = a + leap(i)
    for i in range (0,y2):
        b = b + leap(i)
    for i in range (m1 - 1):
        a = a + m[i]
        if (leap (y1) == 366 and i == 1):
            a = a + 1
    for i in range (m2 - 1):
        b = b + m[i]
        if (leap (y2) == 366 and i == 1):
            b = b + 1
    print(abs(a - b))
def __starting_point():
    main()

__starting_point()

def f(y, m, d):    
    return 365 * y + 31 * m  + d + ((y - 1) // 4 - (y - 1) // 100 + (y - 1) // 400) - ((2 + int(y % 4 != 0 or (y % 100 == 0 and y % 400 != 0))) * (m > 2) + (m > 4) + (m > 6) + (m > 9) + (m > 11))
print(abs(f(*map(int, input().split(':'))) - f(*map(int, input().split(':')))))

t = [0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]
def g(y, m):
    return int(m > 2 and y % 4 == 0 and (y % 100 != 0 or y % 400 == 0))
def h(y):
    return y // 4 - y // 100 + y // 400
def f(y, m, d):    
    nonlocal t
    return 365 * y + t[m] + d + h(y - 1) + g(y, m)
print(abs(f(*map(int, input().split(':'))) - f(*map(int, input().split(':')))))

import datetime

def solve(date1,date2):
    d1 = datetime.datetime(int(date1[0]),int(date1[1]),int(date1[2]))
    d2 = datetime.datetime(int(date2[0]),int(date2[1]),int(date2[2]))
    print(abs((d2-d1).days))

date1 = input()
date2 = input()

solve(date1.split(':'),date2.split(':'))


import datetime
a, b, c = map(int, input().split(':'))
d1 = datetime.date(a, b, c)
a, b, c = map(int, input().split(':'))
d2 = datetime.date(a, b, c)
d3 = abs(d2 - d1)
print(d3.days)

dm = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def leap(y):
    return y % 4 == 0 and y != 1900
def dn(y, m, d):
    return d + sum(dm[i] + (i == 2 and leap(y)) for i in range(m))
d = sorted(list(map(int, input().split(':'))) for i in range(2))
if d[0][0] == d[1][0]:
    print(dn(*d[1]) - dn(*d[0]))
else:
    print(365 + leap(d[0][0]) - dn(*d[0]) + sum(365 + leap(i) for i in range(d[0][0] + 1, d[1][0])) + dn(*d[1]))

from datetime import date
from datetime import timedelta

a = input()
a = [int(x) for x in a.split(":")]
b = input()
b = [int(x) for x in b.split(":")]

x = date(a[0],a[1],a[2])
y = date(b[0],b[1],b[2])

if x > y:
  x,y = y,x

ans = 0
while x != y:
  x = x + timedelta(days=1)
  ans+=1
print(ans)



def s():
    import datetime
    dt = datetime.datetime
    print(abs((dt(*list(map(int,input().split(':'))))-dt(*list(map(int,input().split(':'))))).days))
s()


from datetime import date
y1,m1,d1=list(map(int,input().split(':')))
y2,m2,d2=list(map(int,input().split(':')))

a=date(y1,m1,d1)
b=date(y2,m2,d2)
print(abs((b-a).days))



from datetime import date
y1,m1,d1 = list(map(int,input().split(':')))
y2,m2,d2 = list(map(int,input().split(':')))
date1 = date(y1,m1,d1)
date2 = date(y2,m2,d2)
print(abs((date2-date1).days))