program main
  implicit none
  
  integer :: n, f, b, fb
  
  read *, n
  
  f = n/3
  b = n/5
  fb = n/15
  
  print *, n*(n+1)/2 - 3*(f*(f+1)/2) - 5*(b*(b+1)/2) + 15*(fb*(fb+1)/2)
  
  stop
end program main