program am
implicit none
integer(16)::N
integer(16)::ANS,SUM3,SUM5,SUM15
read*,N
SUM3=3_16*sigma(N/3_16)
SUM5=5_16*sigma(N/5_16)
SUM15=15_16*sigma(N/15_16)
ANS=sigma(N)-SUM3-SUM5+SUM15
print"(I0)",ANS
contains
pure integer(16) function sigma(i)
integer(16),intent(in)::i
sigma=(i*(i+1))/2
end function
end program am