program ABC162B
    implicit none
    integer(8)::N,i,ans
    read*,N
    ans=0
    do i=1,N
        if(mod(i,15)/=0.and.mod(i,5)/=0.and.mod(i,3)/=0)ans=ans+i
    end do

    print'(i0)',ans
end program ABC162B