program main
    implicit none
    integer(8) n
    integer(8) sum, n3, n5, n15
    integer(8) sub
    read(*,*) n

    sum = n*(n+1)/2
    
    n3 = (n - mod(n,3))/3
    n5 = (n - mod(n,5))/5
    n15 = (n - mod(n,15))/15
    
    sub = 3*n3*(n3+1)/2 + 5*n5*(n5+1)/2 - 15*n15*(n15+1)/2

    write(*,*) sum-sub
    
end program