      program b162
        integer*8 i
        integer*8 N,M
        read(*,*)N
        M = 0.D0

        do i = 1,N

        if (.not.((mod(i,3)== 0 ).or.(mod(i,5) == 0)))then
            M = M +i
        endif
        enddo
        write(*,*)M

        end program



