#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <functional>
#include <set>
#include <queue>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
using std::string;
using std::to_string;
string size1(string dm) {
    if (dm.length() == 1)
        dm = '0' + dm;
    return dm;
}

string size2(string y) {
    if (y.length() == 4) return y;
    while (4 - y.length() != 0)
        y = '0' + y;
    return y;
}


class Date {
 private:
    int mdays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    int Leap(int m) {
        if (m == 2) {
            return IsLeap() ? 29 : 28;
        } else {
            return mdays[m - 1];
        }
    }
    int day;
    int month;
    int year;

 public:
    Date(int year, int month, int day) {
        this->year = year;
        this->month = month;
        this->day = day;
    }

    bool IsLeap() {
        if (this->year % 4 == 0) {
            if (this->year % 100 == 0) {
                if (this->year % 400 == 0) {
                    return true;
                }
                else {
                    return false;
                }
            }
            else {
                return true;
            }
        }
        else {
            return false;
        }
    }

    string ToString() {
        string s1 = size1(to_string(this->day));
        string s2 = size1(to_string(this->month));
        string s3 = size2(to_string(this->year));
        string s = s1 + '.' + s2 + '.' + s3;
        return s;
    }

    Date DaysLater(int days) {
        int d, m = this->month, y = this->year;
        days += day;
        int count_d = Leap(m);
        while (days > count_d) {
            days -= count_d;
            if (m == 12) {
                m = 1;
                y += 1;
            }
            else {
                m += 1;
            }
            count_d = Leap(m);
        }
        d = days;
        Date dat(y, m, d);
        return dat;
    }

    int DaysLeft(const Date& date) {
        Date dat(date.year, date.month, date.day);
        int days = dat.day;
        while (this->month != dat.month || this->year != dat.year) {
            if (dat.month == 1) {
                dat.year -= 1;
                dat.month = 12;
            }
            else {
                dat.month -= 1;
            }
            days += Leap(dat.month);
        }
        days -= this->day;
        return days;
    }
};