public class Main {

    // Method to check leap year
    static boolean isLeapYear(int year) {
        if (year % 400 == 0) return true;
        if (year % 100 == 0) return false;
        return year % 4 == 0;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String date = sc.nextLine().trim();

        // Check format YYYY-MM-DD
        if (!date.matches("\\d{4}-\\d{2}-\\d{2}")) {
            System.out.println("Invalid input");
            return;
        }

        try {
            String[] parts = date.split("-");
            int year = Integer.parseInt(parts[0]);
            int month = Integer.parseInt(parts[1]);
            int day = Integer.parseInt(parts[2]);

            // Validate year
            if (year < 1900 || year > 2100) {
                System.out.println("Invalid input");
                return;
            }

            // Validate month
            if (month < 1 || month > 12) {
                System.out.println("Invalid input");
                return;
            }

            // Days in months
            int[] daysInMonth = { 
                31, 28, 31, 30, 31, 30, 
                31, 31, 30, 31, 30, 31 
            };

            // Adjust February for leap year
            if (isLeapYear(year)) {
                daysInMonth[1] = 29;
            }

            // Validate day
            if (day < 1 || day > daysInMonth[month - 1]) {
                System.out.println("Invalid input");
                return;
            }

            // Calculate day number of year
            int dayOfYear = 0;
            for (int i = 0; i < month - 1; i++) {
                dayOfYear += daysInMonth[i];
            }
            dayOfYear += day;

            System.out.println(dayOfYear);

        } catch (Exception e) {
            System.out.println("Invalid input");
        }
    }
}