while True:
    try:
        x=int(input())
        z=list(range(1,x+1))
        m=[]
        if x>30000 or x<=0:
            break
        else:
            for i in range(x):
                z[i]=str(z[i])
                if int(z[i])%7==0 or "7" in z[i]:
                    m.append(i)
            n=len(m)
            print(n)
    except:
        break