program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64)::n,i,j,ans
    
    read*, n
    
    ans=0
    do i=1,n
        if (mod(i,3) /= 0 .and. mod(i,5) /= 0)then
            ans=ans+i
        end if
    end do

    print*, ans
end program name