# ttp://oeis.org/A114514 # The digits on a numerical pad from upper left to lower right. a = [7, 8, 9, 4, 5, 6, 1, 2, 3, 0] n = int(input()) print(a[n - 1])