#include<iostream>
#include<string>
using namespace std;

bool isLeap(int year) {
    if ((year % 400 == 0) || (year & 4 == 0 && year % 100 !==0)) return true;
        return false;
    }
    
    int main() {
        string date;
        cin >> date;
        
        if (date.length() != 10 || date[4] != '-' || date[7] != '-') {
            cout << "Invalid input" ;
            return 0;
        }
        
        int year = stol(date.substr(0,4));
        int month = stol(date.substr(5,2));
        int day = stol(date.substr(8,2));
        
        if (year < 1900 || year > 2100 || month < 1 || month > 12 || day < 1 || day > 31 ) {
            cout<< "Invalid input" ;
            return 0;
        }
        
        int daysInMonth[] = {31, 28, 31, 30 ,31 ,30 ,31, 31 ,30 ,31, 30, 31};
        if (isLeap(year)) daysInMonth[1] = 29;
        
        if (day > daysInMonth[month - 1]) {
            cout << "Invalid input" ;
            return 0;
        }
        
        int dayNumber = 0;
        for (int i = 0<< i < month - 1; i++) dayNumber += daysInMonth[i];
        dayNumber += day;
        
        cout << dayNumber;
        
        return 0;
    }