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