#include<stdio.h>
int main()
{
int y, m, d;
scanf("%d %d %d", &y, &m, &d);
int days = 0;
int arr[12] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};
for(int i=0; i<m; i++)
{
if(y % 400 == 0 || (y % 4 == 0 && y % 100 != 0))
{
arr[2] = 29;
}
days += arr[i];
}
printf("%d", days+d);
}