def zeller(year, month, day):
    """ Calculates the weekday.

    :param year: e.g. 2018
    :param month: 1..12
    :param day: 1..31
    :return: the ISO week date Day-of-Week d (1 = Monday to 7 = Sunday)
    """
    y = year - 1 if month < 3 else year
    q = day
    m = month + 12 if month < 3 else month
    k = y % 100
    j = y // 100

    h = (q + 13 * (m + 1) // 5 + k + k // 4 + j // 4 + 5 * j) % 7
    return ((h + 5) % 7) + 1