#include <iostream>
using namespace std;
int timevault[2][12] = {{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
int main() {
    int year , month , day;
    while (cin >> year >> month >> day) 
    { // 注意 while 处理多个 case
       int temp = 0;
       if(((year % 4 == 0) && (year % 100 != 0)) || year % 400 == 0)
       {
          for (int i = 0; i <= month - 2; i++) 
          {
          temp += timevault[1][i];
          }
          temp += day;
          cout << temp << endl;
       } 
       else 
       {
          for (int i = 0; i <= month - 2; i++) 
          {
          temp += timevault[0][i];
          }
          temp += day;
          cout << temp << endl;
       }
    }
    return 0;
}
// 64 位输出请用 printf("%lld")