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

int main() {
    int days = 0;
    string year, month, day;
    cin >> year >> month >> day;

    /*一个年份如果能被4整除但不能被100整除,则是闰年。
一个年份如果能被400整除,也是闰年。
例如,2024年是闰年,因为它能被4整除且不能被100整除。而1900年不能被400整除,所以不是闰年。*/
    array<int, 12> months{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    
    bool bistrue = (stoi(year) % 4 == 0 && stoi(year) % 100 != 0);

    if(stoi(month) == 1){
        cout << day << endl;
    }else{
        for(int i = 0; i < stoi(month)-1; ++i){
            days += months[i];
        }
        days += stoi(day);
        if(bistrue)
            days += 1;
        cout << days << endl;
    }
    
}
// 64 位输出请用 printf("%lld")