Your local library needs your help! Given the expected and actual return dates for a library book, create a program that calculates the fine (if any). The fee structure is as follows: 

If the book is returned on or before the expected return date, no fine will be charged (i.e.: $fine=0)$.
If the book is returned after the expected return day but still within the same calendar month and year as the expected return date, $fine=15\ \text{Hackos}\ \times\ \text{(the number of days later)}$. 
If the book is returned after the expected return month but still within the same calendar year as the expected return date, the $fine=500\ \text{Hackos}\ \times\ \text{(the number of months rate)}$.   
If the book is returned after the calendar year in which it was expected, there is a fixed fine of $10000\ \textbf{Hackos}$.

Charges are based only on the least precise measure of lateness.  For example, whether a book is due January 1, 2017 or December 31, 2017, if it is returned January 1, 2018, that is a year late and the fine would be $10,000\ \text{Hackos}$.  

Example 

$d1,m1,y1=14,7,2018$ 

$d2,m2,y2=5,7,2018$  

The first values are the return date and the second are the due date.  The years are the same and the months are the same.  The book is $14-5=9$ days late.  Return $9*15=135$.  

Function Description  

Complete the libraryFine function in the editor below.  

libraryFine has the following parameter(s):  

d1, m1, y1: returned date day, month and year, each an integer  
d2, m2, y2: due date day, month and year, each an integer    

Returns  

int:  the amount of the fine or $\mbox{o}$ if there is none

Input Format

The first line contains $3$ space-separated integers, $d1,m1,y1$, denoting the respective $\boldsymbol{day}$, $\textit{month}$, and $year$ on which the book was returned. 

The second line contains $3$ space-separated integers, $d2,m2,y2$, denoting the respective $\boldsymbol{day}$, $\textit{month}$, and $year$ on which the book was due to be returned.

Constraints

$1\leq d1,d2\leq31$     
$1\leq m1,m2\leq12$     
$1\leq y1,y2\leq3000$  
$\textbf{It is generated that the dates will be valid Gregion calendar dates.}$  

Sample Input
9 6 2015
6 6 2015

Sample Output
45

Explanation

Given the following dates: 

Returned: $d1=9,m1=6,y1=2015$ 

Due: $d2=6,m2=6,y2=2015$

Because $y2\equiv y1$, we know it is less than a year late. 

Because $\textit{m2}\equiv\textit{m1}$, we know it's less than a month late. 

Because $d2<d1$, we know that it was returned late (but still within the same month and year).  

Per the library's fee structure, we know that our fine will be $15\ \text{Hackos}\ \times\ (\#\ \text{days rate})$. We then print the result of $15\times(d1-d2)=15\times(9-6)=45$ as our output.

Difficulty: EASY

Solutions:
def fine(actual, expected):
	if actual[2] > expected[2]:
		return 10000
	elif actual[2] == expected[2]:
		if actual[1] > expected[1]:
			return 500 * (actual[1] - expected[1])
		elif actual[1] == expected[1]:
			if actual[0] > expected[0]:
				return 15 * (actual[0] - expected[0])
	return 0
actual_return_date = input().split(' ')
expected_return_date = input().split(' ')
actual_return_date = [int(number) for number in actual_return_date]
expected_return_date = [int(number) for number in expected_return_date]
print(fine(actual_return_date, expected_return_date))


def main(N):
	sum0 = 0
	D = N[0][0] - N[1][0]
	M = N[0][1] - N[1][1]
	Y = N[0][2] - N[1][2]
	if D > 0 and M == 0 and (Y == 0):
		sum0 = 15 * D
	elif M > 0 and Y == 0:
		sum0 = 500 * M
	elif Y > 0:
		sum0 = 10000 * Y
	print(sum0)
N = [list(map(int, input().split(' '))) for i in [1, 2]]
main(N)


date1 = input().split()
date1 = [int(i) for i in date1]
date2 = input().split()
date2 = [int(i) for i in date2]
if date2[2] != date1[2]:
	if date2[2] < date1[2]:
		c = 10000
		print(c)
	else:
		print(0)
elif date2[1] != date1[1]:
	if date2[1] < date1[1]:
		b = abs(date2[1] - date1[1])
		c = b * 500
		print(c)
	else:
		print(0)
elif date2[0] != date1[0]:
	if date2[0] < date1[0]:
		b = abs(date2[0] - date1[0])
		c = b * 15
		print(c)
	else:
		print(0)
else:
	print(0)


(d2, m2, y2) = map(int, input().split())
(d1, m1, y1) = map(int, input().split())
if y2 - y1 > 0:
	print(10000)
elif y2 - y1 == 0 and m2 - m1 > 0:
	print(500 * (m2 - m1))
elif y2 - y1 == 0 and m2 - m1 == 0 and (d2 - d1 > 0):
	print(15 * (d2 - d1))
else:
	print(0)


(dayReceived, monthReceived, yearReceived) = list(map(int, input().split(' ')))
(dayExpected, monthExpected, yearExpected) = list(map(int, input().split(' ')))
if yearReceived < yearExpected:
	print(0)
elif yearReceived > yearExpected:
	print(10000)
elif monthReceived < monthExpected:
	print(0)
elif monthReceived > monthExpected:
	print(500 * (monthReceived - monthExpected))
elif dayReceived <= dayExpected:
	print(0)
else:
	print(15 * (dayReceived - dayExpected))


def fine(a, e):
	d1 = int(a[0])
	m1 = int(a[1])
	y1 = int(a[2])
	d2 = int(e[0])
	m2 = int(e[1])
	y2 = int(e[2])
	if y1 > y2:
		return 10000
	if y1 < y2:
		return 0
	if m1 > m2:
		return 500 * (m1 - m2)
	if m1 < m2:
		return 0
	if d1 > d2:
		return 15 * (d1 - d2)
	return 0

def main():
	a = input().split()
	e = input().split()
	print(fine(a, e))
main()


res = list(reversed([int(x) for x in input().split()]))
due = list(reversed([int(x) for x in input().split()]))

def calc(res, due):
	if res[0] < due[0]:
		return 0
	if res[0] > due[0]:
		return 10000
	if res[1] < due[1]:
		return 0
	if res[1] > due[1]:
		return 500 * (res[1] - due[1])
	if res[2] < due[2]:
		return 0
	if res[2] > due[2]:
		return 15 * (res[2] - due[2])
	return 0
print(calc(res, due))


(a_day, a_month, a_year) = input().strip().split(' ')
(a_day, a_month, a_year) = (int(a_day), int(a_month), int(a_year))
(e_day, e_month, e_year) = input().strip().split(' ')
(e_day, e_month, e_year) = (int(e_day), int(e_month), int(e_year))
from datetime import date
actual = date(a_year, a_month, a_day)
expected = date(e_year, e_month, e_day)
if e_year == a_year:
	if a_month > e_month:
		fine = 500 * (a_month - e_month)
		print(fine)
	elif a_month < e_month:
		print('0')
	elif a_month == e_month:
		if a_day > e_day:
			fine = 15 * (actual - expected).days
			print(fine)
		elif a_day <= e_day:
			print('0')
elif a_year > e_year:
	print('10000')
elif a_year < e_year:
	print('0')


D = 0
M = 1
Y = 2
actual = [int(x) for x in input().split(' ')]
expected = [int(x) for x in input().split(' ')]
if actual[Y] > expected[Y]:
	fine = 10000
elif actual[Y] == expected[Y] and actual[M] > expected[M]:
	fine = 500 * (actual[M] - expected[M])
elif actual[M] == expected[M] and actual[D] > expected[D]:
	fine = 15 * (actual[D] - expected[D])
else:
	fine = 0
print(fine)


a = input().split(' ')
b = input().split(' ')
if int(b[2]) < int(a[2]):
	fine = 10000
elif (int(b[1]) < int(a[1])) & (int(b[2]) == int(a[2])):
	fine = 500 * (int(a[1]) - int(b[1]))
elif (int(b[0]) < int(a[0])) & (int(b[1]) == int(a[1])) & (int(b[2]) == int(a[2])):
	fine = 15 * (int(a[0]) - int(b[0]))
else:
	fine = 0
print(fine)


listActual = list(map(int, input().split()))
listExpected = list(map(int, input().split()))
if (listActual[0] < listExpected[0]) & (listActual[1] <= listExpected[1]) & (listActual[2] <= listExpected[2]) | (listActual[2] < listExpected[2]) | (listActual[1] < listExpected[1]) & (listActual[2] == listExpected[2]):
	print(0)
elif (listActual[1] == listExpected[1]) & (listActual[2] == listExpected[2]):
	nDays = listActual[0] - listExpected[0]
	print(nDays * 15)
elif listActual[2] == listExpected[2]:
	nMonths = listActual[1] - listExpected[1]
	print(nMonths * 500)
else:
	print(10000)


from datetime import datetime
inp = list(map(int, input().split()))
at = datetime(inp[2], inp[1], inp[0])
inp = list(map(int, input().split()))
et = datetime(inp[2], inp[1], inp[0])
if at < et:
	print(0)
elif at.year > et.year:
	print(10000)
elif at.year == et.year:
	if at.month == et.month:
		print(15 * (at.day - et.day))
	else:
		print(500 * (at.month - et.month))


(f_d, f_m, f_e) = [int(x) for x in input().split()]
(e_d, e_m, e_e) = [int(x) for x in input().split()]
if f_e > e_e:
	print(10000)
elif f_m > e_m and f_e == e_e:
	print((f_m - e_m) * 500)
elif f_d > e_d and f_e == e_e and (f_m == e_m):
	print((f_d - e_d) * 15)
else:
	print(0)


retDate = input().rstrip().split(' ')
expDate = input().rstrip().split(' ')
if int(retDate[2]) > int(expDate[2]):
	print(10000)
elif int(retDate[2]) == int(expDate[2]):
	if int(retDate[1]) > int(expDate[1]):
		print(500 * (int(retDate[1]) - int(expDate[1])))
	elif int(retDate[1]) == int(expDate[1]):
		if int(retDate[0]) > int(expDate[0]):
			print(15 * (int(retDate[0]) - int(expDate[0])))
		else:
			print(0)
	else:
		print(0)
else:
	print(0)


a = list(map(int, input().split()))
b = list(map(int, input().split()))
fine = 0
if a[2] > b[2]:
	fine = 10000
elif a[2] == b[2]:
	if a[1] > b[1]:
		fine = 500 * (a[1] - b[1])
	elif a[1] == b[1]:
		if a[0] > b[0]:
			fine = 15 * (a[0] - b[0])
print(fine)


(d1, m1, y1) = list(map(int, input().split()))
(d2, m2, y2) = list(map(int, input().split()))
f = 0
if y1 > y2:
	f = 10000
elif y1 == y2:
	if m1 > m2:
		f = 500 * (m1 - m2)
	elif m1 == m2:
		if d1 > d2:
			f = 15 * (d1 - d2)
print(f)


(ActualD, ActualM, ActualY) = input().split()
ActualD = int(ActualD)
ActualM = int(ActualM)
ActualY = int(ActualY)
(ExpD, ExpM, ExpY) = input().split()
ExpD = int(ExpD)
ExpM = int(ExpM)
ExpY = int(ExpY)
Fine = 0
if ActualY == ExpY:
	if ActualM == ExpM:
		if ActualD == ExpD:
			Fine = 0
		elif ActualD > ExpD:
			Fine = 15 * (ActualD - ExpD)
	elif ActualM > ExpM:
		Fine = 500 * (ActualM - ExpM)
elif ActualY > ExpY:
	Fine = 10000
print(Fine)


(Dact, Mact, Yact) = input().split()
Dact = int(Dact)
Mact = int(Mact)
Yact = int(Yact)
(Dexp, Mexp, Yexp) = input().split()
Dexp = int(Dexp)
Mexp = int(Mexp)
Yexp = int(Yexp)
if Yact < Yexp:
	fine = 0
elif Yact > Yexp:
	fine = 10000
elif Mact < Mexp:
	fine = 0
elif Mact > Mexp:
	fine = (Mact - Mexp) * 500
elif Dact <= Dexp:
	fine = 0
else:
	fine = (Dact - Dexp) * 15
print(fine)


actualDate = input().split(' ')
expectedDate = input().split(' ')
fine = 0
differnceInDays = int(actualDate[0]) - int(expectedDate[0])
differenceInMonths = int(actualDate[1]) - int(expectedDate[1])
diffenceInYears = int(actualDate[2]) - int(expectedDate[2])
if diffenceInYears >= 1:
	fine = 10000
elif diffenceInYears == 0:
	if differenceInMonths >= 1:
		fine = 500 * differenceInMonths
	elif differenceInMonths == 0:
		if differnceInDays >= 1:
			fine = 15 * differnceInDays
	else:
		fine = 0
else:
	fine = 0
print(fine)


import os
import sys
import re

def main():
	(retDay, retMonth, retYear) = map(int, input().split())
	(day, month, year) = map(int, input().split())
	if year < retYear:
		fine = 10000
	elif year > retYear:
		fine = 0
	elif month < retMonth:
		fine = 500 * (retMonth - month)
	elif month > retMonth:
		fine = 0
	elif day < retDay:
		fine = 15 * (retDay - day)
	else:
		fine = 0
	print(fine)
main()


n = ''.join(input()).split()
k = ''.join(input()).split()
if int(n[2]) / int(k[2]) != 1 and k[2] < n[2]:
	print(10000)
elif int(n[1]) / int(k[1]) != 1 and k[1] < n[1] and (k[2] <= n[2]):
	print((int(n[1]) - int(k[1])) * 500)
elif n[0] > k[0] and k[1] <= n[1] and (k[2] <= n[2]):
	print((int(n[0]) - int(k[0])) * 15)
else:
	print(0)


actl_rtn_dt = input().split()
exptd_rtn_dt = input().split()
actl_day = int(actl_rtn_dt[0])
actl_month = int(actl_rtn_dt[1])
actl_year = int(actl_rtn_dt[2])
exptd_day = int(exptd_rtn_dt[0])
exptd_month = int(exptd_rtn_dt[1])
exptd_year = int(exptd_rtn_dt[2])
if actl_day <= exptd_day and actl_month <= exptd_month and (actl_year <= exptd_year):
	print(0)
elif actl_month < exptd_month and actl_year <= exptd_year:
	print(0)
elif actl_year < exptd_year:
	print(0)
elif actl_day > exptd_day and actl_month <= exptd_month and (actl_year <= exptd_year):
	print(15 * (actl_day - exptd_day))
elif actl_month > exptd_month and actl_year <= exptd_year:
	print(500 * (actl_month - exptd_month))
else:
	print(10000)


(d1, m1, y1) = [int(i) for i in input().split(' ')]
(d2, m2, y2) = [int(i) for i in input().split(' ')]
x1 = y1 * 10000 + m1 * 100 + d1
x2 = y2 * 10000 + m2 * 100 + d2
if x1 < x2:
	print(0)
elif y1 > y2:
	print(10000)
elif m1 > m2:
	print(500 * (m1 - m2))
else:
	print(15 * (d1 - d2))


import sys
actual_dates = sys.stdin.readline().strip()
expected_dates = sys.stdin.readline().strip()
(a_d, a_m, a_y) = map(lambda x: int(x), actual_dates.split())
(e_d, e_m, e_y) = map(lambda x: int(x), expected_dates.split())
if a_y < e_y:
	print('0')
elif a_y > e_y:
	print('10000')
elif a_m < e_m:
	print('0')
elif a_m > e_m:
	print((a_m - e_m) * 500)
elif a_d < e_d:
	print('0')
elif a_d > e_d:
	print((a_d - e_d) * 15)
else:
	print('0')


(ad, am, ay) = map(int, input().split())
(ed, em, ey) = map(int, input().split())
if ay > ey:
	print(10000)
elif am > em and ay >= ey:
	print(500 * (am - em))
elif ad > ed and am >= em and (ay >= ey):
	print(15 * (ad - ed))
else:
	print(0)


actual_return = list(map(int, input().strip().split(' ')))
exp_return = list(map(int, input().strip().split(' ')))
if actual_return[2] == exp_return[2]:
	if actual_return[1] == exp_return[1]:
		if actual_return[0] <= exp_return[0]:
			print(0)
		else:
			print(15 * (actual_return[0] - exp_return[0]))
	elif actual_return[1] < exp_return[1]:
		print(0)
	else:
		print(500 * (actual_return[1] - exp_return[1]))
elif actual_return[2] < exp_return[2]:
	print(0)
else:
	print(10000)


from datetime import date
(day, month, year) = [int(x) for x in input().split()]
actualReturnDate = date(year, month, day)
(day, month, year) = [int(x) for x in input().split()]
expectedReturnDate = date(year, month, day)
fine = 0
if actualReturnDate > expectedReturnDate:
	delta = actualReturnDate - expectedReturnDate
	if actualReturnDate.year == expectedReturnDate.year and actualReturnDate.month == expectedReturnDate.month:
		fine = 15 * delta.days
	elif actualReturnDate.year == expectedReturnDate.year:
		fine = 500 * (actualReturnDate.month - expectedReturnDate.month)
	else:
		fine = 10000
print(fine)


date2 = list(map(int, input().split()))
date1 = list(map(int, input().split()))
if date2[2] - date1[2] > 0:
	fine = 10000
elif date2[1] - date1[1] > 0 and date2[2] - date1[2] == 0:
	fine = (date2[1] - date1[1]) * 500
elif date2[0] - date1[0] > 0 and date2[2] - date1[2] == 0 and (date2[1] - date1[1] == 0):
	fine = 15 * (date2[0] - date1[0])
else:
	fine = 0
print(fine)


(actD, actM, actY) = input().split()
(actD, actM, actY) = (int(actD), int(actM), int(actY))
(expD, expM, expY) = input().split()
(expD, expM, expY) = (int(expD), int(expM), int(expY))
fine = 0
if expY < actY:
	fine += (actY - expY) * 10000
elif expM < actM and expY <= actY:
	fine += (actM - expM) * 500
elif expD < actD and expM <= actM and (expY <= actY):
	fine += (actD - expD) * 15
print(fine)


def getFee():
	returned = [int(n) for n in input().split()]
	should = [int(n) for n in input().split()]
	years = returned[2] - should[2]
	months = returned[1] - should[1]
	days = returned[0] - should[0]
	if years > 0:
		return 10000
	elif years == 0:
		if months > 0:
			return 500 * months
		elif months == 0:
			if days > 0:
				return 15 * days
	return 0
print(getFee())


return_date = list(map(int, input().split()))
due_date = list(map(int, input().split()))
date_diff = [return_date[x] - due_date[x] for x in range(3)]
DAY = 0
MONTH = 1
YEAR = 2
fine = 0
if date_diff[YEAR] < 0 or (date_diff[YEAR] == 0 and date_diff[MONTH] < 0) or (date_diff[YEAR] == 0 and date_diff[MONTH] == 0 and (date_diff[DAY] <= 0)):
	fine = 0
elif date_diff[MONTH] == 0 and date_diff[YEAR] == 0:
	fine = 15 * date_diff[DAY]
elif date_diff[YEAR] == 0:
	fine = 500 * date_diff[MONTH]
else:
	fine = 10000
print(str(fine))


returnDate = input()
actualDate = input()
ret = returnDate.split(' ')
act = actualDate.split(' ')
if act[2] > ret[2]:
	print('0')
elif ret[2] > act[2]:
	print('10000')
elif act[1] > ret[1]:
	print('0')
elif ret[1] > act[1]:
	print((int(ret[1]) - int(act[1])) * 500)
elif ret[0] > act[0]:
	print((int(ret[0]) - int(act[0])) * 15)
else:
	print('0')


cur = input().split()
due = input().split()
c = 0
if int(cur[2]) > int(due[2]):
	c = 10000
elif int(cur[2]) == int(due[2]):
	if int(cur[1]) > int(due[1]):
		c = 500 * (int(cur[1]) - int(due[1]))
	elif int(cur[1]) == int(due[1]):
		if int(cur[0]) > int(due[0]):
			c = 15 * (int(cur[0]) - int(due[0]))
print(c)


returned = list(map(int, input().split()))
due = list(map(int, input().split()))
fine = max((returned[0] - due[0]) * 15, (returned[1] - due[1]) * 500, (returned[2] - due[2]) * 10000)
if returned[2] * 10000 + returned[1] * 100 + returned[0] > due[2] * 10000 + due[1] * 100 + due[0]:
	print(fine)
else:
	print(0)


import fileinput
input_list = []
for line in fileinput.input():
	L = [int(i) for i in line.split()]
	input_list.append(L)
act = input_list[0]
exp = input_list[1]
act_day = act[0]
act_mth = act[1]
act_yr = act[2]
exp_day = exp[0]
exp_mth = exp[1]
exp_yr = exp[2]
if act_yr > exp_yr:
	hackos = 10000
elif act_yr == exp_yr and act_mth > exp_mth:
	hackos = 500 * (act_mth - exp_mth)
elif act_yr == exp_yr and act_mth == exp_mth and (act_day > exp_day):
	hackos = 15 * (act_day - exp_day)
else:
	hackos = 0
print(hackos)


ad = list(map(int, input().split()))
ed = list(map(int, input().split()))

def calc_fine(ad, ed):
	if ad[2] < ed[2]:
		return 0
	elif ad[2] == ed[2]:
		if ad[1] < ed[1]:
			return 0
		elif ad[1] == ed[1]:
			if ad[0] <= ed[0]:
				return 0
			else:
				return 15 * (ad[0] - ed[0])
		else:
			return 500 * (ad[1] - ed[1])
	else:
		return 10000
print(calc_fine(ad, ed))


import datetime
(rd, rm, ry) = input().split(' ')
(rd, rm, ry) = (int(rd), int(rm), int(ry))
(ed, em, ey) = input().split(' ')
(ed, em, ey) = (int(ed), int(em), int(ey))
if ey < ry:
	print(10000)
elif em < rm and ey == ry:
	print((rm - em) * 500)
elif ed < rd and em == rm and (ey == ry):
	print((rd - ed) * 15)
else:
	print(0)


(returnDay, returnMonth, returnYear) = map(int, input().split())
(dueDay, dueMonth, dueYear) = map(int, input().split())
if returnYear > dueYear:
	fine = 10000
elif returnYear == dueYear:
	if returnMonth > dueMonth:
		fine = 500 * (returnMonth - dueMonth)
	elif returnMonth == dueMonth and returnDay > dueDay:
		fine = 15 * (returnDay - dueDay)
	else:
		fine = 0
else:
	fine = 0
print(fine)


import sys
(D_a, M_a, Y_a) = list(map(int, sys.stdin.readline().split()))
(D_e, M_e, Y_e) = list(map(int, sys.stdin.readline().split()))
if Y_a < Y_e or (Y_a == Y_e and M_a < M_e) or (Y_a == Y_e and M_a == M_e and (D_a <= D_e)):
	print(0)
elif Y_a == Y_e and M_a == M_e:
	print(15 * (D_a - D_e))
elif Y_a == Y_e:
	print(500 * (M_a - M_e))
else:
	print(10000)


from datetime import datetime
returnedarray = input().split()
expectedarray = input().split()

def days_between(d1, d2):
	d1 = datetime.strptime(d1, '%d-%m-%Y')
	d2 = datetime.strptime(d2, '%d-%m-%Y')
	return (d2 - d1).days

def diff_month(d1, d2):
	d1 = datetime.strptime(d1, '%d-%m-%Y')
	d2 = datetime.strptime(d2, '%d-%m-%Y')
	return (d1.year - d2.year) * 12 + d1.month - d2.month

def diff_year(d1, d2):
	d1 = datetime.strptime(d1, '%d-%m-%Y')
	d2 = datetime.strptime(d2, '%d-%m-%Y')
	return d1.year - d2.year
expecteddate = expectedarray[0] + '-' + expectedarray[1] + '-' + expectedarray[2]
returneddate = returnedarray[0] + '-' + returnedarray[1] + '-' + returnedarray[2]
dif = days_between(expecteddate, returneddate)
if dif <= 0:
	print(0)
elif diff_month(returneddate, expecteddate) <= 1 and diff_year(returneddate, expecteddate) <= 0:
	print(dif * 15)
elif diff_month(returneddate, expecteddate) > 1 and diff_year(returneddate, expecteddate) <= 0:
	print(diff_month(returneddate, expecteddate) * 500)
elif diff_year(returneddate, expecteddate) >= 1:
	print(10000)


returned = input().split()
due = input().split()
returned = [int(num) for num in returned]
due = [int(num) for num in due]
if int(str(returned[2]).zfill(4) + str(returned[1]).zfill(2) + str(returned[0]).zfill(2)) <= int(str(due[2]).zfill(4) + str(due[1]).zfill(2) + str(due[0]).zfill(2)):
	print(0)
elif returned[2] > due[2]:
	print('10000')
elif returned[1] > due[1]:
	print((returned[1] - due[1]) * 500)
elif returned[0] > due[0]:
	print((returned[0] - due[0]) * 15)


turnin = list(map(int, input().split()))
due = list(map(int, input().split()))
fine = 0
if turnin[2] != due[2]:
	if turnin[2] > due[2]:
		fine = 10000
elif turnin[1] != due[1]:
	if turnin[1] > due[1]:
		fine = (turnin[1] - due[1]) * 500
elif turnin[0] != due[0]:
	if turnin[0] > due[0]:
		fine = (turnin[0] - due[0]) * 15
print(fine)


(d1, m1, y1) = (int(x) for x in input().split())
(d2, m2, y2) = (int(x) for x in input().split())
if y1 > y2:
	print(10000)
elif y1 < y2:
	print(0)
elif m1 > m2:
	print((m1 - m2) * 500)
elif m1 < m2:
	print(0)
elif d1 > d2:
	print((d1 - d2) * 15)
else:
	print(0)


actualDate = list(map(int, input().split()))
expectedDate = list(map(int, input().split()))
difference = [actualDate[index] - expectedDate[index] for index in range(3)]
if difference[2] < 0:
	print(0)
elif difference[1] < 0 and difference[2] <= 0:
	print(0)
elif difference[0] <= 0 and difference[1] <= 0 and (difference[2] <= 0):
	print(0)
elif difference[2] > 0:
	print(10000)
elif difference[1] > 0:
	print(500 * difference[1])
else:
	print(15 * difference[0])


from sys import stdin

def check_dates(actual, expect):
	year_diff = int(actual[2]) - int(expect[2])
	month_diff = int(actual[1]) - int(expect[1])
	day_diff = int(actual[0]) - int(expect[0])
	if year_diff > 0:
		return 10000
	elif month_diff > 0 and year_diff == 0:
		return 500 * month_diff
	elif day_diff > 0 and month_diff == 0:
		return 15 * day_diff
	return 0
actual_date = stdin.readline()
expect_date = stdin.readline()
actuals = actual_date.strip().split()
expects = expect_date.strip().split()
print(check_dates(actuals, expects))


(d1, m1, y1) = [int(i) for i in input().split()]
(d2, m2, y2) = [int(i) for i in input().split()]
if y1 < y2 or (y1 == y2 and (m1 < m2 or (m1 == m2 and d1 <= d2))):
	print('0')
elif d1 > d2 and m1 == m2 and (y1 == y2):
	print((d1 - d2) * 15)
elif m1 > m2 and y1 == y2:
	print(500 * (m1 - m2))
else:
	print('10000')


def calculate_fine(due_date, return_date):
	if return_date.year == due_date.year:
		if return_date.month == due_date.month:
			return 15 * (return_date.day - due_date.day)
		else:
			return 500 * (return_date.month - due_date.month)
	else:
		return 10000

def is_late(due_date, return_date):
	if return_date.year < due_date.year:
		return False
	elif return_date.year == due_date.year:
		if return_date.month < due_date.month:
			return False
		elif return_date.month == due_date.month:
			if return_date.day <= due_date.day:
				return False
			else:
				return True
		else:
			return True
	else:
		return True

class LibraryDate(object):

	def __init__(self, date):
		self.day = int(date[0])
		self.month = int(date[1])
		self.year = int(date[2])
return_dt = LibraryDate(input().split())
due_dt = LibraryDate(input().split())
if is_late(due_dt, return_dt):
	print(calculate_fine(due_dt, return_dt))
else:
	print(0)


ad = [int(i) for i in input().split()]
ed = [int(i) for i in input().split()]
if ad[2] > ed[2]:
	print(10000)
elif ad[2] < ed[2]:
	print(0)
elif ad[1] > ed[1]:
	print(500 * (ad[1] - ed[1]))
elif ad[1] < ed[1]:
	print(0)
elif ad[0] > ed[0]:
	print(15 * (ad[0] - ed[0]))
else:
	print(0)


(aDD, aMM, aYY) = list(map(int, input().split()))
(eDD, eMM, eYY) = list(map(int, input().split()))
fine = 0
if aYY <= eYY and aMM <= eMM and (aDD <= eDD):
	fine = 0
elif aYY <= eYY and aMM < eMM:
	fine = 0
elif aYY < eYY:
	fine = 0
elif aYY == eYY and aMM == eMM:
	fine = (aDD - eDD) * 15
elif aYY == eYY:
	fine = (aMM - eMM) * 500
elif aYY > eYY:
	fine = 10000
print(fine)


a = [int(d) for d in input().split()]
e = [int(d) for d in input().split()]
fine = 0
if a[2] > e[2]:
	fine = 10000
elif a[2] == e[2] and a[1] > e[1]:
	fine = 500 * (a[1] - e[1])
elif a[2] == e[2] and a[1] == e[1] and (a[0] > e[0]):
	fine = 15 * (a[0] - e[0])
print(fine)


actual = input().split(' ')
expected = input().split(' ')
actual = [int(s) for s in actual]
expected = [int(s) for s in expected]
if actual[2] < expected[2]:
	print(0)
elif actual[2] == expected[2] and actual[1] < expected[1]:
	print(0)
elif actual[2] == expected[2] and actual[1] == expected[1] and (actual[0] < expected[0]):
	print(0)
elif actual[2] != expected[2]:
	print(10000)
elif actual[1] != expected[1]:
	fine = abs(actual[1] - expected[1]) * 500
	print(fine)
else:
	fine = abs(actual[0] - expected[0]) * 15
	print(fine)


A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
if A[2] > B[2]:
	print(10000)
elif A[2] == B[2]:
	if A[1] > B[1]:
		print(500 * (A[1] - B[1]))
	elif A[1] == B[1]:
		if A[0] > B[0]:
			print(15 * (A[0] - B[0]))
		else:
			print(0)
	else:
		print(0)
else:
	print(0)


def fine(actual, expected):
	if actual[2] > expected[2]:
		return 10000
	elif actual[2] == expected[2]:
		if actual[1] > expected[1]:
			return 500 * (actual[1] - expected[1])
		elif actual[1] == expected[1]:
			if actual[0] > expected[0]:
				return 15 * (actual[0] - expected[0])
	return 0
actual_return_date = input().split(' ')
expected_return_date = input().split(' ')
actual_return_date = [int(number) for number in actual_return_date]
expected_return_date = [int(number) for number in expected_return_date]
print(fine(actual_return_date, expected_return_date))


book_return = input().strip().split()
expected_return = input().strip().split()
DAY_FINE = 15
MONTH_FINE = 500
YEAR_FINE = 10000
fine = 0
if book_return[0] > expected_return[0] and book_return[1] == expected_return[1] and (book_return[2] == expected_return[2]):
	days_delay = int(book_return[0]) - int(expected_return[0])
	fine = DAY_FINE * days_delay
elif book_return[1] > expected_return[1] and book_return[2] == expected_return[2]:
	months_delay = int(book_return[1]) - int(expected_return[1])
	fine = MONTH_FINE * months_delay
elif book_return[2] > expected_return[2]:
	fine = YEAR_FINE
print(fine)


from datetime import datetime, date
R = datetime.strptime(input(), '%d %m %Y')
E = datetime.strptime(input(), '%d %m %Y')
if (R - E).days < 1:
	print(0)
elif R.year > E.year:
	print(10000)
elif R.month > E.month:
	print(500 * (R.month - E.month))
else:
	print(15 * (R.day - E.day))


actual = input().split()
expected = input().split()
actual_dmy = {'d': int(actual[0]), 'm': int(actual[1]), 'y': int(actual[2])}
expected_dmy = {'d': int(expected[0]), 'm': int(expected[1]), 'y': int(expected[2])}
if actual_dmy['y'] != expected_dmy['y']:
	if actual_dmy['y'] > expected_dmy['y']:
		print(10000)
	else:
		print(0)
elif actual_dmy['m'] != expected_dmy['m']:
	print(500 * max(0, actual_dmy['m'] - expected_dmy['m']))
elif actual_dmy['d'] != expected_dmy['d']:
	print(15 * max(0, actual_dmy['d'] - expected_dmy['d']))
else:
	print(0)


(dr, mr, yr) = input().split()
(dr, mr, yr) = (int(dr), int(mr), int(yr))
(dd, md, yd) = input().split()
(dd, md, yd) = (int(dd), int(md), int(yd))
hackos = 0
if yr == yd:
	if mr == md:
		if dr <= dd:
			hackos = 0
		else:
			hackos = (dr - dd) * 15
	elif mr < md:
		hackos = 0
	else:
		hackos = (mr - md) * 500
elif yr < yd:
	hackos = 0
else:
	hackos = 10000
print(hackos)


act = [int(x) for x in input().split()]
due = [int(x) for x in input().split()]
if act[2] > due[2]:
	print(10000)
	exit()
elif act[2] == due[2] and act[1] > due[1]:
	print(500 * (act[1] - due[1]))
	exit()
elif act[1] == due[1] and act[0] > due[0]:
	print(15 * (act[0] - due[0]))
else:
	print(0)


(da, ma, ya) = map(int, input().split())
(de, me, ye) = map(int, input().split())
if ya > ye:
	print(10000)
elif ya == ye and ma > me:
	print(500 * (ma - me))
elif ya == ye and ma == me and (da > de):
	print(15 * (da - de))
else:
	print(0)


(da, ma, ya) = map(int, input().split())
(de, me, ye) = map(int, input().split())
if ya > ye:
	print(10000)
elif ya == ye:
	if ma > me:
		print(500 * (ma - me))
	elif ma == me:
		if da > de:
			print(15 * (da - de))
		else:
			print(0)
	else:
		print(0)
else:
	print(0)


actual = [int(x) for x in input().split(' ')]
expected = [int(x) for x in input().split(' ')]
if actual[2] > expected[2]:
	print(str(10000))
elif actual[2] == expected[2]:
	if actual[1] > expected[1]:
		actual_month = actual[1]
		expected_month = expected[1]
		print(str(500 * (actual_month - expected_month)))
	elif actual[1] == expected[1]:
		if actual[0] > expected[0]:
			actual_day = actual[0]
			expected_day = expected[0]
			print(str(15 * (actual_day - expected_day)))
		else:
			print(str(0))
	else:
		print(str(0))
else:
	print(str(0))


from datetime import date

def calculateHackos(actual, expected):
	actual_date = date(actual[2], actual[1], actual[0])
	expected_date = date(expected[2], expected[1], expected[0])
	if actual_date.year > expected_date.year:
		return 10000
	if actual_date.year < expected_date.year:
		return 0
	if actual_date.month > expected_date.month:
		return (actual_date.month - expected_date.month) * 500
	if actual_date.month < expected_date.month:
		return 0
	if actual_date.day > expected_date.day:
		return (actual_date.day - expected_date.day) * 15
	return 0
actual = [int(v) for v in input().split(' ')]
expected = [int(v) for v in input().split(' ')]
print(calculateHackos(actual, expected))


d1 = list(map(int, input().split()))
d2 = list(map(int, input().split()))
if d1[-1] > d2[-1]:
	print(10000)
elif d1[-1] == d2[-1]:
	if d1[1] > d2[1]:
		print(500 * (d1[1] - d2[1]))
	elif d1[1] == d2[1]:
		if d1[0] > d2[0]:
			print(15 * (d1[0] - d2[0]))
		else:
			print(0)
	else:
		print(0)
else:
	print(0)


(return_d, return_m, return_y) = map(int, input().split())
(expected_d, expected_m, expected_y) = map(int, input().split())
if return_y > expected_y:
	print(10000)
elif return_y == expected_y:
	if return_m > expected_m:
		print(500 * (return_m - expected_m))
	elif return_m == expected_m:
		if return_d > expected_d:
			print(15 * (return_d - expected_d))
		else:
			print(0)
	else:
		print(0)
else:
	print(0)


l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
if l1[2] > l2[2]:
	print(10000)
elif l1[2] < l2[2]:
	print(0)
elif l1[1] > l2[1]:
	print(500 * (l1[1] - l2[1]))
elif l1[1] < l2[1]:
	print(0)
elif l1[0] > l2[0]:
	print(15 * (l1[0] - l2[0]))
else:
	print(0)


import sys
lines = sys.stdin.read().split('\n')
returned = [int(x) for x in lines[0].split(' ')]
expected = [int(x) for x in lines[1].split(' ')]
if returned[2] - expected[2] < 0:
	print(0)
elif returned[2] - expected[2] > 0:
	print(10000)
elif returned[1] - expected[1] < 0:
	print(0)
elif returned[1] - expected[1] > 0:
	print(int((returned[1] - expected[1]) * 500))
elif returned[0] - expected[0] <= 0:
	print(0)
elif returned[0] - expected[0] > 0:
	print(int((returned[0] - expected[0]) * 15))


import datetime
s = list(map(int, input().split(' ')))
a = datetime.date(s[2], s[1], s[0])
s = list(map(int, input().split(' ')))
e = datetime.date(s[2], s[1], s[0])
daysLate = (a - e).days
if daysLate > 0:
	if a.year != e.year:
		fine = 10000
	elif a.month == e.month:
		fine = 15 * daysLate
	else:
		monthsLate = 12 * a.year + a.month - (12 * e.year + e.month)
		fine = 500 * monthsLate
else:
	fine = 0
print(fine)


from datetime import datetime

def calculateFine(actualDate, expectedDate):
	if actualDate <= expectedDate:
		return 0
	if actualDate.year != expectedDate.year:
		return 10000
	if actualDate.month != expectedDate.month:
		return 500 * (actualDate.month - expectedDate.month)
	if actualDate.day != expectedDate.day:
		return 15 * (actualDate.day - expectedDate.day)
actualDateStr = input()
expectedDateStr = input()
actualDate = datetime.strptime(actualDateStr, '%d %m %Y')
expectedDate = datetime.strptime(expectedDateStr, '%d %m %Y')
fine = calculateFine(actualDate, expectedDate)
print(fine)


actual = tuple((int(x) for x in input().split(' ')))
expect = tuple((int(x) for x in input().split(' ')))
(dd, dm, dy) = (actual[i] - expect[i] for i in range(3))
if dy > 0:
	print(10000)
elif dy == 0 and dm > 0:
	print(dm * 500)
elif dm == 0 and dd > 0:
	print(dd * 15)
else:
	print(0)


from datetime import datetime, timedelta
x1 = input().split(' ')
x2 = input().split(' ')
years = int(x1[2]) - int(x2[2])
months = int(x1[1]) - int(x2[1])
days = int(x1[0]) - int(x2[0])
if years >= 1:
	print('10000')
elif months >= 1 and years >= 0:
	print(str(500 * months))
elif days >= 1 and months >= 0 and (years >= 0):
	print(str(15 * days))
else:
	print('0')


(d1, m1, y1) = [int(num) for num in input().split(' ')]
(d2, m2, y2) = [int(num) for num in input().split(' ')]
if y1 < y2 or (y1 == y2 and m1 < m2) or (y1 == y2 and m1 == m2 and (d1 <= d2)):
	print('0')
elif y1 != y2:
	print('10000')
elif m1 != m2:
	print(str(500 * (m1 - m2)))
else:
	print(str(15 * (d1 - d2)))


(ad, am, ay) = map(int, input().split())
(ed, em, ey) = map(int, input().split())
if ay < ey:
	print(0)
elif ay == ey:
	if am < em:
		print(0)
	elif am == em:
		if ad <= ed:
			print(0)
		else:
			print(abs(ed - ad) * 15)
	else:
		print(abs(em - am) * 500)
else:
	print(10000)


def calc_fine(due_date, return_date):
	(due_d, due_m, due_y) = due_date
	(re_d, re_m, re_y) = return_date
	if due_y < re_y:
		return 10000
	elif due_y == re_y and due_m < re_m:
		return 500 * (re_m - due_m)
	elif due_y == re_y and due_m == re_m and (due_d < re_d):
		return 15 * (re_d - due_d)
	else:
		return 0
return_date = [int(_) for _ in input().split()]
due_date = [int(_) for _ in input().split()]
print(calc_fine(due_date, return_date))


(dreturn, mreturn, yreturn) = map(int, input().split())
(dexpected, mexpected, yexpected) = map(int, input().split())

def fine(dreturn, mreturn, yreturn, dexpected, mexpected, yexpected):
	if yreturn < yexpected:
		return 0
	if yreturn == yexpected:
		if mreturn < mexpected:
			return 0
		if mreturn == mexpected:
			if dreturn <= dexpected:
				return 0
			return abs(dreturn - dexpected) * 15
		if mreturn == mexpected + 1:
			if dreturn <= dexpected:
				return abs(dreturn - dexpected) * 15
		if mreturn > mexpected:
			return 500 * abs(mreturn - mexpected)
	if yreturn > yexpected:
		return 10000
	if yreturn == yexpected + 1:
		if mreturn < mexpected:
			return 500 * (abs(mreturn - mexpected) - (1 if dreturn < dexpected else 0))
		if mreturn == mexpected:
			if dreturn < dexpected:
				return 500 * (abs(mreturn - mexpected) - (1 if dreturn < dexpected else 0))
	return 10000
print(fine(dreturn, mreturn, yreturn, dexpected, mexpected, yexpected))


def convertToInt(stringList):
	intList = []
	for i in stringList:
		intList.append(int(i))
	return intList
date1 = convertToInt(input().split())
date2 = convertToInt(input().split())
if date1[2] < date2[2] or (date1[2] == date2[2] and date1[1] < date2[1]) or (date1[2] == date2[2] and date1[1] == date2[1] and (date1[0] < date2[0])) or (date1[2] == date2[2] and date1[1] == date2[1] and (date1[0] == date2[0])):
	print(0)
elif date1[2] > date2[2]:
	print(10000)
elif date1[1] > date2[1]:
	print(500 * (date1[1] - date2[1]))
elif date1[0] > date2[0]:
	print(15 * (date1[0] - date2[0]))


import os
import sys
import re

def main():
	(retDay, retMonth, retYear) = map(int, input().split())
	(day, month, year) = map(int, input().split())
	if year < retYear:
		fine = 10000
	elif year > retYear:
		fine = 0
	elif month < retMonth:
		fine = 500 * (retMonth - month)
	elif month > retMonth:
		fine = 0
	elif day < retDay:
		fine = 15 * (retDay - day)
	else:
		fine = 0
	print(fine)
main()


ret = list(map(int, input().split()))
due = list(map(int, input().split()))
fine = 0
if ret[2] > due[2]:
	fine = 10000
if ret[1] > due[1] and ret[2] == due[2]:
	fine = 500 * (ret[1] - due[1])
if ret[0] > due[0] and ret[1] == due[1] and (ret[2] == due[2]):
	fine = 15 * (ret[0] - due[0])
print(fine)


actual = input().strip().split()
expected = input().strip().split()
if int(actual[2]) > int(expected[2]):
	print(10000)
elif int(actual[1]) > int(expected[1]) and int(actual[2]) == int(expected[2]):
	print(500 * (int(actual[1]) - int(expected[1])))
elif int(actual[0]) > int(expected[0]) and int(actual[1]) == int(expected[1]) and (int(actual[2]) == int(expected[2])):
	print(15 * (int(actual[0]) - int(expected[0])))
else:
	print(0)


(actualDay, actualMonth, actualYear) = (int(x) for x in input().split())
(expectedDay, expectedMonth, expectedYear) = (int(x) for x in input().split())
if expectedYear < actualYear:
	print('10000')
elif expectedYear > actualYear:
	print('0')
elif expectedMonth < actualMonth:
	print('%d' % ((actualMonth - expectedMonth) * 500))
elif expectedMonth > actualMonth:
	print('0')
elif expectedDay < actualDay:
	print('%d' % ((actualDay - expectedDay) * 15))
else:
	print('0')


r = list(map(int, list(input().split(' '))))
e = list(map(int, list(input().split(' '))))
if not r[2] == e[2]:
	if r[2] > e[2]:
		print(10000)
	else:
		print(0)
elif not r[1] == e[1]:
	if r[1] > e[1]:
		print((r[1] - e[1]) * 500)
	else:
		print(0)
elif not r[0] == e[0]:
	if r[0] > e[0]:
		print((r[0] - e[0]) * 15)
	else:
		print(0)
else:
	print(0)


(rd, rm, ry) = [int(x) for x in input().split()]
(ed, em, ey) = [int(x) for x in input().split()]
if ry > ey:
	print(10000)
elif ry < ey:
	print(0)
elif rm > em:
	print(500 * (rm - em))
elif rm < em:
	print(0)
elif rd > ed:
	print(15 * (rd - ed))
else:
	print(0)


def finer():
	ani = input()
	ann = input()
	ani = ani.split()
	ann = ann.split()
	anid = ani[0]
	anim = ani[1]
	aniy = ani[2]
	annd = ann[0]
	annm = ann[1]
	anny = ann[2]
	result_fine = 0
	if anny > aniy:
		print(result_fine)
	elif anny == aniy:
		if anim > annm:
			result_fine = (int(anim) - int(annm)) * 500
			print(result_fine)
		elif anim < annm:
			print(result_fine)
		elif anim == annm:
			if anid > annd:
				result_fine = (int(anid) - int(annd)) * 15
				print(result_fine)
			elif anid < annd:
				print(result_fine)
			elif anid == annd:
				print(result_fine)
	elif anny < aniy:
		result_fine = 10000
		print(result_fine)
finer()


from datetime import date
actual = date(*reversed(tuple(map(int, input().split()))))
expect = date(*reversed(tuple(map(int, input().split()))))
if actual <= expect:
	print(0)
elif actual.month == expect.month and actual.year == expect.year:
	print((actual - expect).days * 15)
elif actual.year == expect.year:
	print((actual.month - expect.month) * 500)
else:
	print(10000)


def sol(day1, month1, year1, day2, month2, year2):
	if year1 == year2:
		if month1 == month2:
			if day1 == day2:
				print(0)
			elif day1 < day2:
				print(0)
			else:
				print((day1 - day2) * 15)
		elif month1 < month2:
			print(0)
		else:
			print((month1 - month2) * 500)
	elif year1 < year2:
		print(0)
	else:
		print(10000)
N = input()
M = input()
N1 = list(map(int, N.split(' ')))
M1 = list(map(int, M.split(' ')))
sol(N1[0], N1[1], N1[2], M1[0], M1[1], M1[2])


a = map(int, input().split())
e = map(int, input().split())
actual = list(a)
expect = list(e)
fine = 0
if actual[2] > expect[2]:
	fine = 10000
elif actual[2] < expect[2]:
	fine = 0
elif actual[1] > expect[1]:
	fine = 500 * (actual[1] - expect[1])
elif actual[1] < expect[1]:
	fine = 0
elif actual[0] > expect[0]:
	fine = 15 * (actual[0] - expect[0])
else:
	fine = 0
print(fine)


act = [int(i) for i in input().split(' ')]
exp = [int(i) for i in input().split(' ')]
if act[2] > exp[2]:
	fine = 10000
elif act[2] < exp[2]:
	fine = 0
elif act[2] == exp[2] and act[1] < exp[1]:
	fine = 0
elif act[2] == exp[2] and act[1] == exp[1] and (act[0] <= exp[0]):
	fine = 0
elif act[2] == exp[2] and act[1] == exp[1] and (act[0] > exp[0]):
	fine = 15 * (act[0] - exp[0])
else:
	fine = 500 * (act[1] - exp[1])
print(fine)


(rDay, rMonth, rYear) = map(int, input().split())
(aDay, aMonth, aYear) = map(int, input().split())
if rYear > aYear:
	fine = 10000
elif rYear < aYear:
	fine = 0
elif rMonth > aMonth:
	fine = 500 * (rMonth - aMonth)
elif rMonth < aMonth:
	fine = 0
elif rDay > aDay:
	fine = 15 * (rDay - aDay)
else:
	fine = 0
print(fine)


(dr, mr, yr) = list(map(int, input().split()))
(de, me, ye) = list(map(int, input().split()))
fine = 0
if yr < ye:
	fine = 0
elif yr > ye:
	fine = 10000
elif mr < me:
	pass
elif mr > me:
	fine = 500 * (mr - me)
elif dr < de:
	pass
elif dr > de:
	fine = 15 * (dr - de)
print(fine)


act = [int(i) for i in input().split()]
exp = [int(i) for i in input().split()]
mn = 0
dy = 0
if act[2] > exp[2]:
	print('10000')
elif act[1] > exp[1] and act[2] == exp[2]:
	mn = act[1] - exp[1]
	print('%d' % (mn * 500))
elif act[0] > exp[0] and act[2] == exp[2] and (act[1] == exp[1]):
	dy = act[0] - exp[0]
	print('%d' % (mn + dy * 15))
else:
	print('0')


import datetime
import calendar
returned_date_in = reversed([int(x) for x in input().split()])
expected_date_in = reversed([int(x) for x in input().split()])
returned_date = datetime.date(*returned_date_in)
expected_date = datetime.date(*expected_date_in)
date_diff = returned_date - expected_date
if returned_date <= expected_date:
	fine = 0
elif returned_date.month == expected_date.month and returned_date.year == expected_date.year:
	fine = (returned_date - expected_date).days * 15
elif returned_date.year == expected_date.year:
	returned_date_aligned = datetime.date(returned_date.year, returned_date.month, 1)
	expected_date_aligned = datetime.date(expected_date.year, expected_date.month, 1)
	fine = round((returned_date_aligned - expected_date_aligned).days / (365 / 12)) * 500
else:
	fine = 10000
print(fine)


def parse_date(s):
	a = s.split()
	return (int(a[0]), int(a[1]), int(a[2]))
actual = parse_date(input())
expected = parse_date(input())
if actual[2] < expected[2] or (actual[2] == expected[2] and (actual[1] < expected[1] or (actual[1] == expected[1] and actual[0] <= expected[0]))):
	print(0)
elif actual[2] == expected[2] and actual[1] == expected[1]:
	print(15 * (actual[0] - expected[0]))
elif actual[2] == expected[2]:
	print(500 * (actual[1] - expected[1]))
else:
	print(10000)


actual = list(map(int, input().split()))
expected = list(map(int, input().split()))
if actual[2] < expected[2]:
	print(0)
elif actual[2] > expected[2]:
	print(10000)
elif actual[1] < expected[1]:
	print(0)
elif actual[1] > expected[1]:
	print(500 * (actual[1] - expected[1]))
elif actual[0] > expected[0]:
	print(15 * (actual[0] - expected[0]))
else:
	print(0)


return_date = list(map(int, input().split()))
due_date = list(map(int, input().split()))
day = return_date[0] - due_date[0]
month = return_date[1] - due_date[1]
year = return_date[2] - due_date[2]
if year > 0:
	fine = 10000
elif year == 0 and month > 0:
	fine = month * 500
elif year == 0 and month == 0 and (day > 0):
	fine = day * 15
else:
	fine = 0
print(fine)


date_returned = list(map(int, input().split(' ')))
date_expected = list(map(int, input().split(' ')))
fine = 0
if date_returned[2] > date_expected[2]:
	fine = 10000
elif date_returned[2] < date_expected[2]:
	fine = 0
elif date_returned[1] > date_expected[1]:
	fine = 500 * (date_returned[1] - date_expected[1])
elif date_returned[1] < date_expected[1]:
	fine = 0
elif date_returned[0] > date_expected[0]:
	fine = 15 * (date_returned[0] - date_expected[0])
print(fine)


(d, m, y) = (0, 1, 2)
ac_return = list(map(int, input().split(' ')))
ex_return = list(map(int, input().split(' ')))
fine = 0
if ac_return[y] < ex_return[y]:
	fine = 0
elif ac_return[y] > ex_return[y]:
	fine = 10000
elif ac_return[m] > ex_return[m]:
	fine = 500 * (ac_return[m] - ex_return[m])
elif ac_return[d] > ex_return[d] and ac_return[m] == ex_return[m]:
	fine = 15 * (ac_return[d] - ex_return[d])
print(fine)


received = [int(x) for x in input().split(' ')[0:3]]
due = [int(x) for x in input().split(' ')[0:3]]
owed = 0
if received[2] == due[2]:
	if received[1] == due[1]:
		if received[0] > due[0]:
			owed = 15 * (received[0] - due[0])
	elif received[1] > due[1]:
		owed = 500 * (received[1] - due[1])
elif received[2] > due[2]:
	owed = 10000
print(owed)


def library_fine(A, E):
	d = A[0] - E[0]
	m = A[1] - E[1]
	y = A[2] - E[2]
	if y > 0:
		return 10000
	if y == 0 and m > 0:
		return 500 * m
	if y == 0 and m == 0 and (d > 0):
		return 15 * d
	return 0

def main():
	A = [int(i) for i in input().split()]
	E = [int(i) for i in input().split()]
	print(library_fine(A, E))
main()


import fileinput
from datetime import date
input = fileinput.input()
line1 = [int(i) for i in next(input).split(' ')]
line2 = [int(i) for i in next(input).split(' ')]
act = date(year=line1[2], month=line1[1], day=line1[0])
exp = date(year=line2[2], month=line2[1], day=line2[0])
if act < exp:
	print('0')
elif act.year != exp.year:
	print('10000')
elif act.month != exp.month:
	diff = act.month - exp.month
	print(diff * 500)
elif act.day != exp.day:
	diff = act.day - exp.day
	print(diff * 15)
else:
	print('0')


actual = input()
expected = input()
(da, ma, ya) = actual.split()
(de, me, ye) = expected.split()
da = int(da)
ma = int(ma)
ya = int(ya)
de = int(de)
me = int(me)
ye = int(ye)
if ya - ye > 0:
	print(10000)
elif ya - ye == 0 and ma - me > 0:
	print((ma - me) * 500)
elif ya - ye == 0 and ma - me == 0 and (da - de > 0):
	print((da - de) * 15)
else:
	print(0)


returndate = list(map(int, input().split()))
expecteddate = list(map(int, input().split()))
fine = 0
if returndate[2] > expecteddate[2]:
	fine = 10000
elif returndate[2] == expecteddate[2] and returndate[1] > expecteddate[1]:
	fine = 500 * (returndate[1] - expecteddate[1])
elif returndate[1] == expecteddate[1] and returndate[0] > expecteddate[0]:
	fine = 15 * (returndate[0] - expecteddate[0])
print(fine)