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