n = int(input()) word = '285714' l = len(word) pos = n - int(n/l) * l print(word[pos-1])