program main
  implicit none
  integer(8) :: n, i, res
  read *, n
  res = 0
  do i = 1, n
    if (mod(i, 3) == 0) cycle
    if (mod(i, 5) == 0) cycle
    res = res + i
  end do
  print "(i0)", res
end program main
