import datetime N=int(input()) A=datetime.date(2014, 7, 23).weekday() cnt=0 for y in range(2015,2015+400): B=datetime.date(y, 7, 23).weekday() if A==B: cnt+=1 ans=0 now=2**30 while now>0: if 2014+now*400<=N: ans+=now*cnt N-=now*400 now//=2 for y in range(2015,N+1): B=datetime.date(y, 7, 23).weekday() if A==B: ans+=1 print(ans)