#include <iostream>
#include <vector>
using namespace std;

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

int main() 
{
    int i=0;
    int year=0;
    int month=0;
    int day=0;
    int ans=0;
    cin>>year>>month>>day;
    vector <int> a={31,28,31,30,31,30,31,31,30,31,30,31};
    if(isRunyear(year)==1)
    {
        a[1]=29;
    }
    for(i=0;i<month-1;i++)
    {
        ans+=a[i];
    }
    ans+=day;
    cout<<ans;
    return 0;
}