#include<cstdio>
int main(){
	int year, month, day;
	while (scanf("%d %d %d", &year, &month, &day) != EOF){
		int mon[13] = { 0, 31, 28, 31, 30, 31, 30,31, 31, 30, 31, 30, 31 };
		int totalday[11];
		totalday[0] =0;
		for (int i = 1; i <= 12; i++){
			totalday[i] = totalday[i - 1] + mon[i-1];
		}
		bool isrun = year % 400 == 0 || year % 100 != 0 && year % 4 == 0;
		if (isrun&&month>2){
			printf("%d", totalday[month] + day + 1);
		}
		else{
			printf("%d\n", totalday[month] + day);
		}
	}
}