program abc162b
  implicit none

  integer :: n, i, s

  read *, n

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

  print *, s

  stop
end program abc162b