program problemB
  implicit none

real(8) :: a,  d, e
integer(8) :: n, m, yr, l, i, k, j,judge, small, kref, r, b, t, f
integer(8) :: BNUM, RNUM, NMAX, count
character(len=4) :: color


read(*,*) NMAX

count=0
do n=1, NMAX
  t=mod(n,3)
  f=mod(n,5)
  if (t/=0 .and. f/=0) then
    count=n+count
  end if
end do

write(*,*) count


stop
end program
