a=int(input())

def sum30:
  return (1+2+4+7+8+11+13+14+16+17+19+22+23+26+28+29)

def sumx(x):
  ret = 0
  for j in range(1,x):
    if(j%3 != 0 and j%5 != 0):
      ret+=j
  return ret

sum=0
i=1
while(a > 30):
  sum+=i*sum30
  i+=1
  a-=30
sum+=sumx(a)
    
print(sum)