# an analytical approach, using the fact that
# the sum of the sequence 1 to N = N(N+1)/2

num3s = 1000/3
num5s = 999/5
num15s= 1000/15

sum3 = 3*num3s*(num3s+1)/2
sum5 = 5*num5s*(num5s+1)/2
sum15 = 15*num15s*(num15s+1)/2

total = sum3+sum5-sum15

print total
