#include <stdio.h>
int main()
{
    int A[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int i,y,m,d,cnt;
    while(scanf("%d %d %d",&y,&m,&d)!=EOF)
    {
        cnt=0;
        for(i=1;i<m;i++)cnt+=A[i];
        cnt+=d;
    if(y%4==0&&m>2)cnt++;
    printf("%d\n",cnt);
    }
return 0;
}