#include <iostream>

using namespace std;

int daytab[2][13] = {
{
	0,31,28,31,30,31,30,31,31,30,31,30,31	
},
{
	0,31,29,31,30,31,30,31,31,30,31,30,31
}
};

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

int main(){
	int y,m,d;
	
	while(cin >> y >> m >> d){
		int sum = 0;
		for(int i = 0;i < m ;i ++){
			sum += daytab[isLeapYear(y)][i];
		}
		sum += d;
		cout << sum << endl;
	}
	return 0;
}