N = eval(input()) set1 = "142857" mod = N%7 dif = N//7 if N < 7: tmp = set1[0:N] else: tmp = set1 for it in range(dif-1): tmp = tmp + set1 tmp = tmp + set1[0:mod+1] print(eval("0."+tmp))