#include
using namespace std;
int main()
{
int year;
int month;
int day;
int month2 = 28;
cin >> year;
cin >> month;
cin >> day;
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
{
month2 = 29;
}
if (month == 1) cout << day;
if (month == 2) cout << day + 31;
if (month == 3) cout << day+month2+31;
if (month == 4) cout << day + month2 + 31+30;
if (month == 5) cout << day + month2 + 31 + 30+31;
if (month == 6) cout << day + month2 + 31 + 30 + 31+30;
if (month == 7) cout << day + month2 + 31 + 30 + 31 + 30 + 31;
if (month == 8) cout << day + month2 + 31 + 30 + 31 + 30 + 31 + 31;
if (month == 9) cout << day + month2 + 31 + 30 + 31 + 30 + 31 + 31+30;
if (month == 10)cout << day + month2 + 31 + 30 + 31 + 30 + 31 + 31 + 30+31;
if (month == 11)cout << day + month2 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31+30;
if (month == 12)cout << day + month2 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30+31;
return 0;
}