#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

bool isRunYear(int n)
{
    return (n%400==0)  ||  (n%4==0)  &&  (n%100!=0);
}

int main() 
{
    int i=0;
    int year=0;
    int month=0;
    int day=0;
    int count=0;
    vector <int> a={31,28,31,30,31,30,31,31,30,31,30,31};
    while(cin>>year>>month>>day)
    {
        if(count)
        {
            cout<<endl;
        }
        count=1;
        if(isRunYear(year)==1)
        {
            a[1]=29;
        }
        int ans=accumulate(a.begin(),a.begin()+month-1,0);
        ans+=day;
        cout<<ans;
        a[1]=28;
    }
    return 0;
}