#include<iostream>
using namespace std;

int arr[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

bool isRun(int year)
{
	if(year % 4 == 0 && year % 100 != 0) return true;
	if(year % 400 == 0) return true; 
	return false;
}

int main(void)
{
	int year,month,day;
	while(cin >> year >> month >> day)
	{
		int ans = 0;
		if(month <= 2){
			for(int i = 1;i < month;i++) ans += arr[i];
			ans += day;
		}else{
			if(isRun(year)){
				for(int i = 1;i < month;i++){
					if(i == 2) ans += 29;
					else ans += arr[i];
				}
				ans += day;
			}else{
				for(int i = 1;i < month;i++) ans += arr[i];
				ans += day;
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}