      PROGRAM piyo
      IMPLICIT NONE
      integer(16) :: ans,n,i
      
      read*,n
      
      ans = 0
      do i = 1,n
        if( mod(i,3)/=0 .and. mod(i,5)/=0 )then
          ans = ans + i
        endif
      end do
      
      
      print*,ans
      
      
      
      END PROGRAM