#include <string>

class Date {
 public:
    Date(int year, int month, int day)
        : year(year), month(month), day(day) {
    }

    bool IsLeap() const {
        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;
    }

    std::string ToString() {
        std::string output = this->day + "." + this->month + "." + this->year;
        return output;
    }

    Date DaysLater(int days) {
        bool ready = false;
        int year_out = this->year;
        int month_out = this->month;
        int day_out = this->day;
        int days_check;

        day_out += days;

        while (!ready) {
            switch (month_out) {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    days_check = 31;
                    break;

                case 4:
                case 6:
                case 9:
                case 11:
                    days_check = 30;
                    break;

                case 2:
                    if (IsLeap()) 
                        days_check = 29;
                    else
                        days_check = 28;
                    break;

                default:
                    break;
            }

            if (day_out > days_check) {
                day_out -= days_check;
                month_out++;
                if (month_out > 12) {
                    year_out++;
                    month_out = 1;
                }
            } else
                ready = true;
        }
        Date output(year_out, month_out, day_out);
        return output;
    }

    int DaysLeft(const Date& date) {
        int output = 0;
        int abs_now = 0;
        int abs_then = 0;

        abs_now = 365 * this->year + this->year/4 - this->year/100 +
                  this->year/400 + (153*this->month - 457)/5 + this->day - 306;
        abs_then = 365 * date.year + date.year/4 - date.year/100 + date.year/400
                + (153*date.month - 457)/5 + date.day - 306;
        output = abs_then - abs_now;
        return output;
    }
}