def dfx(ipp):
    ip = ipp.split(" ")
    yf = int(ip[1])
    ts = 0
    for _ in range(1,yf):
        if _ == 1:
            ts += 31
        if _ == 2:
            ts += 28
        if _ == 3:
            ts += 31
        if _ == 4:
            ts += 30
        if _ == 5:
            ts += 31
        if _ == 6:
            ts += 30
        if _ == 7:
            ts += 31
        if _ == 8:
            ts += 30
        if _ == 9:
            ts += 31
        if _ == 10:
            ts += 31
        if _ == 11:
            ts += 30
        if _ == 12:
            ts += 31
    if int(ip[0]) % 4== 0:
        ts += 1
    if int(ip[0]) % 100 == 0:
        ts -= 1
    ts += int(ip[2])
              
    return ts
while True:
    try:
        print(dfx(input()))   
    except:
        break