program main
      implicit none
      integer(4) :: n, i
      integer(8) :: cnt

      read *, n

      cnt = 0
      do i= 1, n
        if (( mod(i,3) /= 0 ) .and. ( mod(i,5) /= 0 )) then
          cnt = cnt + i
        end if
      end do
      print *, cnt

end program main
