#include <iostream>
using namespace std;

int Date[13] = {0,31,59,90,120,151,181,212,243,273,304,334,365};

bool IsLeapYear(int _year)
{
    if ((((_year%4==0) && (_year%100 != 0)) || (_year%400 == 0)))
        return true;
    else
        return false;
}
int main()
{
    int year,month,day;
    cin >> year >> month >> day;

    if(IsLeapYear(year) && month > 2) // 这里注意,2月份以下不需要判断闰年加1
        cout << Date[month-1] + day + 1;
    else
        cout << Date[month-1] + day;
    return 0;
}