#include <iostream>
using namespace std;

int main() {
   int year;
   int month;
   int day;
    cin>>year>>month>>day;
    int sum=0;
    int st[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    if(year%4==0&&year%100!=0 ||year%400==0){
            st[1]=29;
        }
    for(int i=0;i<month-1;i++){
        sum+=st[i];
    }
    sum+=day;
    cout<<sum;
}
// 64 位输出请用 printf("%lld")