# python3


def last_digit_of_fibonacci_number_naive(n):
    assert 0 <= n <= 10 ** 7

    if n <= 1:
        return n

    return (last_digit_of_fibonacci_number_naive(n - 1) + last_digit_of_fibonacci_number_naive(n - 2)) % 10


def last_digit_of_fibonacci_number(n):
    assert 0 <= n <= 10 ** 7

    total = n + 1
    list1 = list()
    for i in range(0, total):
        if i <= 1:
            list1.append(i)
        else:
            list1.append((list1[i-1] + list1[i-2]) % 10)
    return list1[n]


if __name__ == '__main__':
    input_n = int(input())
    print(last_digit_of_fibonacci_number(input_n))

f90a86e0f8e232124e1579a96263e07122bc6955
<mask token>

<mask token>


def last_digit_of_fibonacci_number(n):
    assert 0 <= n <= 10 ** 7
    total = n + 1
    list1 = list()
    for i in range(0, total):
        if i <= 1:
            list1.append(i)
        else:
            list1.append((list1[i - 1] + list1[i - 2]) % 10)
    return list1[n]


<mask token>

def last_digit_of_fibonacci_number_naive(n):
    assert 0 <= n <= 10 ** 7
    if n <= 1:
        return n
    return (last_digit_of_fibonacci_number_naive(n - 1) +
        last_digit_of_fibonacci_number_naive(n - 2)) % 10


def last_digit_of_fibonacci_number(n):
    assert 0 <= n <= 10 ** 7
    total = n + 1
    list1 = list()
    for i in range(0, total):
        if i <= 1:
            list1.append(i)
        else:
            list1.append((list1[i - 1] + list1[i - 2]) % 10)
    return list1[n]


<mask token>

def last_digit_of_fibonacci_number_naive(n):
    assert 0 <= n <= 10 ** 7
    if n <= 1:
        return n
    return (last_digit_of_fibonacci_number_naive(n - 1) +
        last_digit_of_fibonacci_number_naive(n - 2)) % 10


def last_digit_of_fibonacci_number(n):
    assert 0 <= n <= 10 ** 7
    total = n + 1
    list1 = list()
    for i in range(0, total):
        if i <= 1:
            list1.append(i)
        else:
            list1.append((list1[i - 1] + list1[i - 2]) % 10)
    return list1[n]


if __name__ == '__main__':
    input_n = int(input())
    print(last_digit_of_fibonacci_number(input_n))

# python3


def last_digit_of_fibonacci_number_naive(n):
    assert 0 <= n <= 10 ** 7

    if n <= 1:
        return n

    return (last_digit_of_fibonacci_number_naive(n - 1) + last_digit_of_fibonacci_number_naive(n - 2)) % 10


def last_digit_of_fibonacci_number(n):
    assert 0 <= n <= 10 ** 7

    total = n + 1
    list1 = list()
    for i in range(0, total):
        if i <= 1:
            list1.append(i)
        else:
            list1.append((list1[i-1] + list1[i-2]) % 10)
    return list1[n]


if __name__ == '__main__':
    input_n = int(input())
    print(last_digit_of_fibonacci_number(input_n))
