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

// 闰年:366 2月 29天
// 平年:365 2月 28天

// 基本规则:如果年份能被 4 整除,则可能是闰年。
// 例外:
// 如果年份能被 100 整除但不能被 400 整除,则是平年。
// 如果年份能被 400 整除,则是闰年。
// 数学表达:
// 闰年条件:(year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)。
// 否则为平年。


int of_day(int y,int m,int d){
    vector<int> v(13);
    
    if((y%4==0 && y%100!=0) || y%400==0) v={0,31,29,31,30,31,30,31,31,30,31,30,31};
    else v={0,31,28,31,30,31,30,31,31,30,31,30,31};

    int ans=0;
    for (int i=1; i<m;i++) {
        ans+=v[i];
    }
    ans+=d;

    return ans;

}


int main() {

    int y,m,d;

    while (cin>>y>>m>>d) {
        cout<<of_day(y,m,d)<<endl;
    }


}
// 64 位输出请用 printf("%lld")