<reponame>ahmedmeshref/Data-Structures-and-Algorithms-assignments<gh_stars>0
# Uses python3
import sys


# def get_fibonacci_last_digit_naive(n):
#     if n <= 1:
#         return n
#
#     previous = 0
#     current = 1
#
#     for _ in range(n - 1):
#         previous, current = current, previous + current
#
#     return current % 10

def get_fibonacci_last_digit(n):
    if n <= 1:
        return n

    previous = 0
    current = 1

    for _ in range(n - 1):
        next = (previous + current) % 10
        previous, current = current, next

    return current


if __name__ == '__main__':
    n = int(input())
    print(get_fibonacci_last_digit(n))

# Uses python3
import sys


# def get_fibonacci_last_digit_naive(n):
#     if n <= 1:
#         return n
#
#     previous = 0
#     current = 1
#
#     for _ in range(n - 1):
#         previous, current = current, previous + current
#
#     return current % 10

def get_fibonacci_last_digit(n):
    if n <= 1:
        return n

    previous = 0
    current = 1

    for _ in range(n - 1):
        next = (previous + current) % 10
        previous, current = current, next

    return current


if __name__ == '__main__':
    n = int(input())
    print(get_fibonacci_last_digit(n))
# Uses python3 # def get_fibonacci_last_digit_naive(n): #     if n <= 1: #         return n # #     previous = 0 #     current = 1 # #     for _ in range(n - 1): #         previous, current = current, previous + current # #     return current % 10