program main
    implicit none
    integer i, n
    integer(selected_int_kind(r=15)) :: total = 0
    read *, n
    do i=1, n
        if ( mod(i, 3) /= 0 .and. mod(i, 5) /= 0) then
            total = total + i
        endif
    enddo
    print *, total
end program main
