#include <iostream>
using namespace std;
int y, m ,d;
int a[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main()
{
while (cin >> y >> m >>d){
if ((!(y % 4) && (y % 100)) || !(y % 400))
a[1] = 29;
for (int i = 0; i < m - 1; ++i)
d += a[i];
cout << d << endl;}
return 0;
}