program main
  implicit none
  integer :: N, i
  integer(8) :: out 
  read(*,*) N
  out = 0
  do i = 1,N
     if ( mod(i,3) == 0 .or. mod(i,5) == 0 ) then
        continue
     else
        out = out + i
     end if
  end do
  write(*,'(i0)') out
end program main