program main
  
  implicit none
  integer(8) :: n, ans, i
  
  read(*,*) n
  
  ans = 0 
  do i = 1, n
    if( mod(i,3) == 0 .and. mod(i,5) == 0 ) then
    else if( mod(i,3) == 0 ) then
    else if( mod(i,5) == 0 ) then
    else
      ans = ans + i
    end if
  end do

  print*, ans 
   
end program main
