Problem:
 Score : 200 points    Problem Statement Let us define the FizzBuzz sequence  a_1,a_2,... as follows:   If both 3 and 5 divides i , a_i=\mbox{FizzBuzz} .  If the above does not hold but 3 divides i , a_i=\mbox{Fizz} .  If none of the above holds but 5 divides i , a_i=\mbox{Buzz} .  If none of the above holds, a_i=i .   Find the sum of all numbers among the first N terms of the FizzBuzz sequence.      Constraints  1 \leq N \leq 10^6         Input Input is given from Standard Input in the following format:  N       Output Print the sum of all numbers among the first N terms of the FizzBuzz sequence.        Sample Input 1 15      Sample Output 1 60  The first 15 terms of the FizzBuzz sequence are:  1,2,\mbox{Fizz},4,\mbox{Buzz},\mbox{Fizz},7,8,\mbox{Fizz},\mbox{Buzz},11,\mbox{Fizz},13,14,\mbox{FizzBuzz}  Among them, numbers are 1,2,4,7,8,11,13,14 , and the sum of them is 60 .       Sample Input 2 1000000      Sample Output 2 266666333332  Watch out for overflow.

Solution (Python):
N = int(input())
s = 0
t = 0
for i in range(1,N+1):
    if (i % 15) == 0 :
        t = 0
    elif (i % 3) == 0:
        t = 0
    elif (i % 5) == 0:
        t = 0
    else:
        t = i
    s = s + t
print(s)

Solution (Python):
def resolve():
    n=int(input())
    a=0
    for i in range(1,n+1):
        if i%3!=0 and i%5!=0:
            a+=i
    print(a)
resolve()

Solution (Python):

import sys

N = int(input())

sum = 0
for i in range(1,N+1):
    if not(i % 3 == 0 or i % 5 == 0):
        sum += i

print(sum)

Solution (Python):
n = int(input())

sum = 0
for i in range(1, n+1):
    if i%3 == 0 or i%5 == 0:
        continue
    else:
        sum += i
print(sum)

Solution (Python):
n = int(input())

k_5 = n // 5
k_3 = n // 3
k_15 = n // 15

sum_5 = 5 * k_5 * (k_5 + 1) / 2 
sum_3 = 3 * k_3 * (k_3 + 1) / 2 
sum_15 = 15 * k_15 * (k_15 + 1) / 2 
sum_n = n * (n+1) / 2

answer = sum_n - sum_3 - sum_5 +sum_15
print(int(answer))

Solution (Python):
N=int(input())
a=0

for i in range(N+1):
  if i%5==0 and i%3==0:
    continue
  elif i%5==0:
    continue
  elif i%3==0:
    continue
    
  else:
    a+=i
    
print(a)

Solution (Python):
N = int(input())

x = 0
for i in range(1, N+1):
  if (i%3!=0) and (i%5!=0):
    x = x + i
    
print(x)

Solution (Python):
N=int(input())

ans=0
for i in range(1,N+1):
    if i%3!=0 and i%5!=0:
        ans+=i
print(ans)

Solution (Python):
a = int(input())

sum = 0
for i in range(a):
    if ((i+1) % 3 == 0 or (i+1) % 5 == 0):
        continue
    else:
        sum += i+1
    
print(sum)

Solution (Python):
N = int(input())
FizzBuzz = 0
for i in range(1, N + 1):
    if (i % 3 != 0) and (i % 5 != 0):
        FizzBuzz += i
print(FizzBuzz)

Solution (Python):
import sys
input = sys.stdin.readline
from itertools import *
from functools import *
from collections import *
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


def main():
    N = int(input())

    total = 0
    for n in range(1, N + 1):
        if n % 3 == 0 and n % 5 == 0:
            pass
        elif n % 3 == 0:
            pass
        elif n % 5 == 0:
            pass
        else:
            total += n
    print(total)


if __name__ == '__main__':
    main()

Solution (Python):

num = int(input())
s = 0
for i in range(1, num+1):
    if i%3!=0 and i%5!=0:
        s += i
print(s)

Solution (Python):
N = int(input())
ans = 0
for i in range(1,N+1):
    if not i%3 == 0:
        if not i%5 == 0:
            ans += i
print(ans)

Solution (Python):
n=int(input())

ans = 0
for i in range(1, n+1):
    if i % 3 !=0 and i % 5 != 0:
        ans += i
print(ans)

Solution (Python):
n=int(input())
k=n%15
l=n//15
m=l*l*60
if k==1:
    print(m+1+15*l)
if k==2 or k==3:
    print(m+3+30*l)
if k==4 or k==5 or k==6:
    print(m+7+45*l)
if k==7:
    print(m+14+60*l)
if k==8 or k==9 or k==10:
    print(m+22+75*l)
if k==11 or k==12:
    print(m+33+90*l)
if k==13:
    print(m+46+105*l)
if k==14:
    print(m+60+120*l)
if k==0:
    print(m)

Solution (Python):
N = int(input())
ans = 0
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i

print(ans)

Solution (Python):
l=[]
n=int(input())
count=1
while 1<=count and count<=n:
    if count%3!=0 and count%5!=0:
        l.append(count)
        count+=1
    else:
        count+=1
k=sum(l)
print(k)

Solution (Python):
def s(n, d):
    a = n // d
    return a * (a + 1) // 2 * d

n = int(input())
a = n * (n + 1) // 2
fb = s(n, 15)
f = s(n, 3)
b = s(n, 5)
print(a - f - b + fb)

Solution (Python):
inputLine=input()

N = int(inputLine)
result = 0

for i in range(1,N+1):
    if i % 3 != 0 and i % 5 != 0:
        result += i

print(result)

Solution (Python):
n=int(input())
s=0
for i in range(1,n+1):
	if i%3!=0 and i%5!=0:
		s+=i
print(s)

Solution (Python):
n = int(input())
ans = 0
for i in range(1, n + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    ans += i
print(ans)

Solution (Python):
N=int(input())
res=0
for n in range(1,N+1):
    if (n%3==0) | (n%5==0):
        continue
    else:
        res=res+n
print(res)

Solution (Python):
n = int(input())




s = 0
for i in range(1, n+1):
    if i%3 != 0 and i%5 != 0:
        s += i

print(s)

Solution (Python):
n = int(input())

ans = (1+n)*n/2 - (n//3)*3*(n//3+1)/2 - (n//5)*5*(n//5+1)/2 + (n//15)*15*(n//15+1)/2
print(int(ans))

Solution (Python):
N = int(input())

ans = 0
for i in range(N):
    i = i + 1
    if i % 3 != 0 and i % 5 != 0:
        ans += i

print(ans)

Solution (Python):
N = int(input())
count = 0
for i in range(1, N + 1):
    if i % 15 == 0:
        continue
    elif i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    count += i
print(count)

Solution (Python):
n = int(input())
a = 0
for i in range(1, n+1):
    if i % 3 != 0 and i % 5 != 0:
        a += i

print(a)

Solution (Python):
N = int(input())

ans = 0
for n in range(1,N+1):
  if n%3==0 or n%5==0:
    pass
  else:
    ans += n
print(ans)

Solution (Python):
N = int(input())
answer = 0
for i in range(1, N + 1):
    if i % 3 != 0 and i % 5 != 0:
        answer += i

print(answer)

Solution (Python):


N = int(input())
A = []
for i in range(1,N+1):
  if not (i%3 == 0 or i%5 == 0):
    A.append(i)
print(sum(A))

Solution (Python):
N = int(input())
All = N*(N+1)/2
fizzbuzz = int(N/15)
FizzBuzz = fizzbuzz*(fizzbuzz+1)/2*15
fizz = int(N/3)
Fizz = fizz*(fizz+1)/2*3
buzz = int(N/5)
Buzz = buzz*(buzz+1)/2*5

print(int(All-Fizz-Buzz+FizzBuzz))

Solution (Python):
print(sum([i for i in range(1,int(input())+1) if i%3!=0 and i%5!=0]))

Solution (Python):
N = int(input())
ans = 0
for i in range(N+1):
    if (i%3 != 0) & (i%5 != 0):
        ans += i
print(ans)

Solution (Python):


n = int(input())
ans = 0

for i in range(1,n+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        ans += i

print(ans)

Solution (Python):



def MI():return map(int,input().split())
def LI():return list(MI())

n=int(input())

def fb(x):
    if x%15==0:
        return 0
    if x%5==0:
        return 0
    if x%3==0:
        return 0
    return x
ans=0
for i in range(1,n+1):
    ans+=fb(i)
    
print(ans)

Solution (Python):
N = int(input())
ans = 0
for i in range(N + 1):
  if i % 3 != 0 and i % 5 != 0:
    ans += i
print(ans)

Solution (Python):
N = int(input())
ans = 0

for i in range(1,N+1):
    
    
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        ans = ans + i
    
print(ans)

Solution (Python):
N = int(input())

ans = 0
for i in range(N + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    ans += i

print(ans)

Solution (Python):
N = int(input())
n3 = N//3
n5 = N//5
n15 = N//15
sum = N*(N+1)//2 - 3 * n3 *(n3+1)//2 - 5 * n5*(n5+1)//2 + 15 * n15*(n15+1)//2
print(sum)

Solution (Python):
a = input()
s = 0
for i in range(1,int(a)+1):
    
    if i % 3 != 0 and i % 5 != 0:

        s += i
    
print(s)

Solution (Python):
n=int(input())
sumt=(1+n)*n//2

def sum(x):
    xn=n//x
    if xn==0:
        return 0
    elif xn==1:
        return x
    else:
        return (x+x*xn)*xn//2

print(sumt-(sum(3)+sum(5)-sum(15)))

Solution (Python):
n = int(input())
l = []
for i in range(n):
  if (i+1) % 3 ==0 or (i+1)%5 ==0:
    k = 0
  else:
    l.append(i + 1)

print(sum(l))

Solution (Python):
N = int(input())
cnt = 0
for n in range(N+1):
  if n%3 != 0 and n%5 != 0:
   cnt = cnt + n
print(cnt)

Solution (Python):
import sys
si = sys.stdin.readline


def main():
    ans = 0
    n = int(si())
    for e in range(1, n+1):
        if e % 3 != 0 and e % 5 != 0:
            ans += e
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
ans = 0
for i in range(N):
    if (i+1)%3 != 0 and (i+1)%5 != 0:
        ans = ans + (i+1)
print(ans)

Solution (Python):
n=int(input())
ans=0
for i in range(n+1):
    if i%3!=0 and i%5!=0:
        ans+=i
print(ans)

Solution (Python):
N = int(input())

sum_all_numbers = ((N + 1) * N) // 2
sum_mul_of_3 = sum([i for i in range(1, N+1) if i % 3== 0])
sum_mul_of_5 = sum([i for i in range(1, N+1) if i % 5 == 0])
sum_mul_of_15 = sum([i for i in range(1, N+1) if i % 15 == 0])

print(sum_all_numbers - sum_mul_of_3 - sum_mul_of_5 + sum_mul_of_15)

Solution (Python):
N = int(input())

print(sum(i for i in range(1,N+1) if (i%3 != 0 and i%5 != 0)))

Solution (Python):
x = int(input())

total = ((x)*(x+1))//2

hm3 = x//3

total = total -((hm3)*(3+(hm3*3)))//2

hm5 = x//5

total = total -((hm5)*(5+(hm5*5)))//2

hm15 = x//15

total = total + ((hm15)*(15+(hm15*15)))//2

print(total)

Solution (Python):
N = int(input())
sum = 0
for i in range(1, N + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        sum += i
print(sum)

Solution (Python):
N=int(input())
a=0
for i in range(N):
 if (i+1)%3==0 or (i+1)%5==0:
  continue
 else:
  a+=(i+1)
print(a)

Solution (Python):
N = int(input())

list = [int(x) for x in range(1,N+1)]

index_3 = [int(x) for x in range(3, N+1, 3)]
index_5 = [int(x) for x in range(5, N+1, 5)]

for i in index_3:
    list[i-1] = 0
for i in index_5:
    list[i-1] = 0

print(sum(list))

Solution (Python):
N = int(input())
def S(x):
  return 0.5 * x * (x+1)
a = N // 3
b = N // 5
c = N // 15

ans = S(N) - 3 * S(a) - 5 * S(b) + 15 * S(c)

print(int(ans))

Solution (Python):
N=int(input())
sum=0
for i in range(1,N+1):
    if i%3==0 or i%5==0:
        continue
    else:
        sum+=i
print(sum)

Solution (Python):
n = int(input())
ans = 0
for i in range(1, n+1):
  if i % 3 != 0 and i % 5 != 0:
    ans += i

print(ans)

Solution (Python):
N = int(input())
count= 0
for s in range(1,N+1):
    if s % 3 != 0 and s % 5 != 0:
        count += s
print(count)

Solution (Python):
N = int(input())
ans=[]
for i in range(N+1):
	if not i%5==0 and not i%3==0:
		ans.append(i)
print(sum(ans))

Solution (Python):
N = int(input())

ans = 0
for i in range(1,N+1):
    if(i%3 == 0 or i%5 == 0):
        continue
    else:
        ans += i

print(ans)

Solution (Python):
n=int(input())

sum=0
for i in range(1,n+1):
    if not(i%3==0 or i%5==0):
        sum+=i

print(sum)

Solution (Python):
n = int(input())

t = 1

x = 0

while t <= n:
    if t % 3 != 0 and t % 5 != 0:
        x += t
    t += 1
    
print(x)

Solution (Python):
N=int(input())
Stot=0.5*N*(N+1)

S3=0.5*(N//3)*(3+3*(N//3))
S5=0.5*(N//5)*(5+5*(N//5))
S15=0.5*(N//15)*(15+15*(N//15))
print(int(Stot-S3-S5+S15))

Solution (Python):
def summ(x):
    return (x*(x+1))//2


n=int(input())
s=summ(n)+15*summ(n//15)-3*summ(n//3)-5*summ(n//5)
print(s)

Solution (Python):
n = int(input())
a = 0
for i in range(n+1):
    if i % 3 != 0 and i % 5 != 0:
        a = a + i
print(a)

Solution (Python):



N = int(input())


def main():
    ans = 0
    for i in range(1, N + 1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
N1=N//15
N2=N%15
a = 60 * N1 + N1*(N1-1)*60
for i in range(1,N2+1):
    if i % 3 != 0 and i % 5 != 0:
        a += i+15*N1
print(a)

Solution (Python):
N=int(input())
A=[]
for i in range(1,N+1):
  if i%3==0 and i%5==0:
    s=0
  elif i%3==0 and i%5!=0:
    s=0
  elif i%3!=0 and i%5==0:
    s=0
  else:
    s=i
  A.append(s)
print(sum(A))

Solution (Python):
N = int(input())

sum = 0
for i in range(1, N + 1):
    if i%3 != 0 and i%5 != 0:
        
        sum += i

print(sum)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

ans = N * (N + 1) // 2
a = (N // 3) * (N // 3 + 1) // 2 * 3
b = (N // 5) * (N // 5 + 1) // 2 * 5
c = (N // 15) * (N // 15 + 1)  // 2 * 15

print(ans - a - b + c)

Solution (Python):
a = int(input())
num_list = []
for i in range(a):
    i +=1
    if i%3 != 0:
        if i%5 != 0:
            num_list.append(i)
print(sum(num_list))

Solution (Python):

a = []
i = 1
N = int(input())

while len(a) < N:
    if (i%3) == 0 or (i%5) == 0:
        a.append(0)
    else:
        a.append(i)
    i += 1

print(sum(a))

Solution (Python):
f = lambda x: x * (x + 1) // 2
n = int(input())
i, j, k = n // 3, n // 5, n // 15
print(f(n) - 3 * f(i) - 5 * f(j) + 15 * f(k))

Solution (Python):
n = int(input())
san = n // 3
go = n // 5
juugo = n // 15
ans = 0
ALL = ((1 + n)*n)//2
three = ((3 + 3*san)*san)//2
five = ((5 + 5*go)*go)//2
juugo = ((15 + 15*juugo)*juugo)//2

ans = ALL - three - five + juugo

print(ans)

Solution (Python):
N=int(input())

ans=0

for i in range(N):
    if (i+1)%3!=0 and (i+1)%5 != 0:
        ans += i+1

print(ans)

Solution (Python):
n = int(input())
ans = 0
for i in range(n):
  i += 1
  if (i % 3 == 0) or (i % 5==0):
    pass
  else:
    ans += i
print(ans)

Solution (Python):
num = int(input())
ans = 0
for x in range(num + 1):
    if x % 3 == 0 or x % 5 == 0: pass
    else: ans += x
print(ans)

Solution (Python):
n = int(input())

ans = 0
for i in range(1, n+1):
    if i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        ans += i

print(ans)

Solution (Python):
def sum_of_multiples(N, n):
    num_of_multiples = N//n
    sum_of_multiples = (n+n*num_of_multiples)*num_of_multiples//2
    return sum_of_multiples


def main(N=None):
    if not N:
        N = int(input())
    sum_all = N*(N+1)//2
    sum_multiples_of_three = sum_of_multiples(N, 3)
    sum_multiples_of_five = sum_of_multiples(N, 5)
    sum_multiples_of_fifteen = sum_of_multiples(N, 15)
    ans = sum_all - sum_multiples_of_three - \
        sum_multiples_of_five + sum_multiples_of_fifteen
    print(ans)
    return ans


if __name__ == "__main__":
  main()

Solution (Python):
N = int(input())
ans = 0
for i in range(1,N+1):
  if i%3 == 0 or i%5 == 0 or i%15 == 0:
    continue
  else:
    ans += i
print(ans)

Solution (Python):
def fizzbuzz(n):
    ans = 0
    for i in range(n):
        if (i+1)%3 != 0 and (i+1)%5 != 0:
            ans += i+1
            
    print(ans)

n = int(input())
fizzbuzz(n)

Solution (Python):
n=int(input())

result=[]
for i in range(1,n+1):
    if i%5!=0 and i%3!=0:
        result.append(i)

print(sum(result))

Solution (Python):






import sys
sys.setrecursionlimit(10000000)


dxdy=((1,0),(0,1))

def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    k,=pin()
    ans=0
    for i in range(1,k+1):
        if i%3!=0 and i%5!=0:
            ans+=i
    print(ans)
    
    
"""         


"""
"""
お前カッコ閉じ,るの忘れてるだろ
"""
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """15"""
        output = """60"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1000000"""
        output = """266666333332"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()

Solution (Python):
n = int(input())

result = 0

for i in range(1, n+1):
  if i%3 != 0 and i%5 != 0:
    result += i

print(result)

Solution (Python):
n = int(input())
ans=0
count=0
for i in range(1,n+1):
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        ans+=i
print(ans)

Solution (Python):
n = int(input())
b = 0
s = 0
for i in range(1,n+1):
    if i%3 == 0 or i%5 == 0:
        continue
    else:
        s += i
        
print(s)

Solution (Python):
n=int(input())
s=0
for i in range(n+1):
  if(i%3!=0 and i%5!=0):
    s+=i
print(s)

Solution (Python):
N = int(input())

ans = 0
for i in range(1, N + 1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i

print(ans)

Solution (Python):
import numpy as np
N = int(input())
S = np.arange(1,N+1)

for i in range(N):
    t = S[i] % 3
    u = S[i] % 5
    if t == 0:
        S[i] = 0
    if u == 0:
        S[i] = 0

print(sum(S))

Solution (Python):
import sys
input=sys.stdin.readline







N = int(input())








a = N // 15
b = 60 * (a**2)
c = a * 15
for i in range(c,N+1):
    if i % 3 != 0 and i % 5 != 0:
        b += i
print(b)

Solution (Python):
a = int(input())
res = (1 + a) * a // 2
three, five, fifteen = 0, 0, 0
if res >= 3:
    three = (3 + a // 3 * 3) * (a // 3) //2
if res >= 5:
    five = (5 + a // 5 * 5) * (a // 5) //2
if res >= 15:
    fifteen = (15 + a // 15 * 15) * (a // 15) //2

print(res - three - five + fifteen)

Solution (Python):
n=int(input())
sums=0
for i in range(1,n+1):
    if((i%3)!=0 and (i%5)!=0):
        sums+=i
print(sums)

Solution (Python):
N = int(input())
count = 0
for i in range(1,N+1):
    if i % 3 != 0:
        if i % 5 != 0:
            count += i         
print(count)

Solution (Python):
n=int(input())
l=[]
for i in range(1,n+1):
    if i%3==0:
        pass
    elif i%5==0:
        pass
    else:
        l.append(i)
print(sum(l))

Solution (Python):
n = int(input())
s = 0
for i in range(1,n+1):
	if i%3 != 0 and i%5 != 0:
		s = s + i
print(s)

Solution (Python):
n = int(input())

ans = 0
for i in range(1,n+1):
    if (i%3 != 0 and i%5 != 0):
        ans += i
print(ans)

Solution (Python):
N=int(input())
count = 0
for i in range(N):
    if not(((i+1)%3 == 0)or((i+1)%5 == 0)):
        count += i+1
print(count)

Solution (Python):
n = int(input())
ans = 0

for i in range(n+1):
    if not (i % 3 == 0) and not(i % 5 == 0):
        ans += i

print(ans)

Solution (Python):
N=int(input())
ans=0
for x in range(1,N+1):
    if x%3!=0 and x%5!=0:
        ans+=x
print(ans)

Solution (Python):
n=int(input())
sum = 0
cnt3 = 0
cnt5 = 0
for i in range(1,n+1):
    cnt3 += 1
    cnt5 += 1
    if cnt3 != 3 and cnt5 != 5:
        sum += i
    if cnt3 == 3:
        cnt3 = 0
    if cnt5 == 5:
        cnt5 = 0
print (sum)

Solution (Python):
mxn = 10**6 + 11
arr = []
for i in range(1,mxn):
    if i % 3 == 0 and i % 5 == 0:
        arr.append(0)
    elif i % 3 == 0:
        arr.append(0)
    elif i%5 == 0:
        arr.append(0)
    else:
        arr.append(i)

n = int(input())
print(sum(arr[:n]))

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '
        
        
    return ret


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  
from math import gcd


def lcm(a, b):
    
    g = gcd(a, b)
    return a * b // g


N = read_a_int()
ans = 0
for i in range(1, N + 1):
    if i % 3 and i % 5:
        ans += i
print(ans)

Solution (Python):
N=int(input())
n_3=N//3
n_5=N//5
n_15=N//15
print((N*(N+1)-3*n_3*(n_3+1)-5*n_5*(n_5+1)+15*n_15*(n_15+1))//2)

Solution (Python):
N = int(input())

mySum = 0

for indx in range(N):
    if ((indx + 1) % 3 != 0) and ((indx + 1) % 5 != 0):
        mySum += (indx + 1)

print(mySum)

Solution (Python):
n=int(input())
ans=0

for i in range(1,n+1):
    if i % 15 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        ans=ans+i
print(ans)

Solution (Python):
n = int(input())

ans = 0

for i in range(n):
  if (i+1)%3 != 0 and (i+1)%5 != 0:
    ans += (i+1)

print(ans)

Solution (Python):
def ifif(s):
  if s:
    print("Yes")
  else:
    print("No")



def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(map(str, input().split()))
def pl(a): print(" ".join(list(map(str, a))))
def ma():return map(int,input().split())
from itertools import accumulate as acc
import operator as op
import copy as cp
import math; import numpy
from bisect import bisect_left as bisl
from bisect import bisect_right as bisr

n=ri()
a=[]
for i in range(1,n+1):
    if i%3==0 or i%5==0:
        a.append(0)
    else:
        a.append(i)

print(sum(a))

Solution (Python):
def SumOfSequence(n):
    t=0
    for i in range(1,n+1):
        if (i%15==0) or (i%3==0) or (i%5==0):
            continue
        else:
            t+=i
    return t
n=int(input())
print(SumOfSequence(n))

Solution (Python):
N = int(input())
n = []
ans = 0
for i in range(N) :
    if (i + 1 ) % 15 == 0 :
        n.append('FizzBuzz')
    elif ( i + 1 ) % 3 == 0 :
        n.append('Fizz')
    elif (i + 1) % 5 == 0 :
        n.append('Buzz')
    else :
        n.append(i + 1)
        ans += i + 1

print(ans)

Solution (Python):
def sum_(s, e):
    return (s + e) * (e - s + 1) / 2

n = int(input())

num_3 = n // 3
num_5 = n // 5
num_15 = n // 15
sum_3 = sum_(1, num_3) * 3
sum_5 = sum_(1, num_5) * 5
sum_15 = sum_(1, num_15) * 15
ans = int(sum_(1, n) - (sum_3 + sum_5 - sum_15))

print(ans)

Solution (Python):
N = int(input())
non_fizzbuzz = [0, ]

for n in range(1, N+1):
    if n%3!=0 and n%5!=0:
        non_fizzbuzz.append(n)
print(sum(non_fizzbuzz))

Solution (Python):
n = int(input())

ans = 1
for i in range(2,n+1):
    if i%3 != 0 and i%5 != 0:
        ans += i
print(ans)

Solution (Python):
N = int(input())

S=0

for i in range(1,N+1):
   if i%3!=0 and i%5!=0:
       S = S+i
print(S)

Solution (Python):
n=int(input())
fbs=0
for i in range(1,n+1):
  if i%3>0 and i%5>0:
    fbs+=i
print(fbs)

Solution (Python):
r = int(input())
sum = 0
for n in range(r+1):
    if n!=0:
        if(n%3==0 and n%5==0):
            pass
        elif(n%3==0):
            pass
        elif(n%5==0):
            pass
        else:
            sum = sum + n
print(sum)

Solution (Python):
N = int(input())
f = 0
b = 0
fb = 0
for i in range(N//3):
    f += (i+1)*3
for i in range(N//5):
    b += (i+1)*5
for i in range(N//15):
    fb += (i+1)*15
s = N*(N+1)/2
ans = s-(f+b-fb)
print(int(ans))

Solution (Python):
N = int(input()) 
a = 0
for i in range(1,N+1):
    if not i%3 == 0 and not i%5 == 0:
        a = a+i
print(a)

Solution (Python):
n = int(input())
ans = 0

for i in range(1, n+1):
  if i%3!=0 and i%5!=0:
    ans += i
    
print(ans)

Solution (Python):





n = int(input())
ans = 0
for i in range(1, n+1):
    if (i%3 != 0) and (i%5 != 0):
        ans += i
print(ans)

Solution (Python):
import numpy as np



first_input = list(map(lambda x:int(x), input().split(" ")))









N = first_input[0]

number_sum = 0
for i in range(1,N+1):
    if i%5!=0 and i%3!=0:
        number_sum = number_sum+i

print(number_sum)

Solution (Python):
n = int(input())

a = 0
for i in range(1, n + 1):
    if (i % 3 is 0) and (i % 5 is 0):
        
        continue
    elif i % 3 is 0:
        
        continue
    elif i % 5 is 0:
        
        continue
    else:
        a += i

print(a)

Solution (Python):
def resolve():
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    print(ans)
resolve()

Solution (Python):
n=int(input())

sum = 0
for i in range(1,n+1):
    if i%3==0 or i%5==0:
        sum = sum
    elif i%3==0 or i%5==0:
        sum = sum+i
    else:
        sum = sum + i

print(sum)

Solution (Python):

N = int(input())
Ans = 0
for i in range(N):
    if (i+1) % 3 !=0 and (1+i) % 5 != 0:
        Ans += i+1
print(int(Ans))

Solution (Python):
n = int(input())
i=1
s=0
while i<=n:
    if i%3==0:
        i+=1
        continue
    elif i%5==0:
        i+=1
        continue
    else:
        s+=i
        i+=1
print(s)

Solution (Python):
X = int(input())
num_sum = 0
for i in range(1,X+1):
    if (i % 3!=0) and (i % 5!=0): 
        num_sum += i
print(num_sum)

Solution (Python):


N = int(input())

v = 0

for i in range(N+1):
    if i % 3 != 0 and i % 5 != 0:
        v+= i

print(v)

Solution (Python):
n = int(input())

ans = 0
for i in range(1,n+1):

    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        ans += i

print(ans)

Solution (Python):




import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    
    
    n=int(readline())
    
    
    ans=0
    for i in range(1,n+1):
        if (i%3)>0 and (i%5)>0:
            ans+=i
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Solution (Python):
N = int(input())
cnt = 0
for i in range(1,N+1):
    if i % 3 !=0 and i % 5 != 0:
        cnt  = cnt +i
print(cnt)

Solution (Python):

n = int(input())
sum = 0
for i in range(n+1):
    if i % 3 != 0 and i % 5 != 0:
        sum += i
print(sum)

Solution (Python):
i = int(input())
a_list=[]
for i in range(1,i+1):
    if i%3!=0 and i%5!=0:
        a_list.append(i)
a=sum(a_list)
print(a)

Solution (Python):
n = int(input())
f = n//3
b = n//5
fb = n//15
print(((1+n)*n//2)-((1+f)*f*3//2)-((1+b)*b*5//2)+((1+fb)*fb*15//2))

Solution (Python):

num_list = []


for i in range(1, int(input())+1):
	
    if i % 3 != 0 and i % 5 != 0:
    	num_list.append(i)

print(sum(num_list))

Solution (Python):
n = int(input())
a = (1+n)*n/2
b = (3 + 3*(n//3))*(n//3)/2
c = (5 + 5*(n//5))*(n//5)/2
d = (15 + 15*(n//15))*(n//15)/2
print(int(a-b-c+d))

Solution (Python):
N = int(input())
total = 0

for i in range(1,N+1):
  if i%3 != 0 and i%5 != 0:
    total += i

print(total)

Solution (Python):
import numpy as np
N = int(input())
S = np.arange(1, N+1)
S = S[S%3 != 0]
S = S[S%5 != 0]
print(sum(map(int, S)))

Solution (Python):
N = int(input())
print(sum([i for i in range(1,N+1) if (i%3!=0 and i%5!=0)]))

Solution (Python):
N = int(input())
ans = 0
for n in range(1, N+1):
  if n % 15 == 0:
    pass
  elif n % 3 == 0:
    pass
  elif n % 5 == 0:
    pass
  else:
    ans += n
print(ans)

Solution (Python):
n = int(input())
l = list("")
for i in range(n + 1):
    if i % 3 != 0 and i % 5 != 0:
        l.append(i)
print(sum(l))

Solution (Python):
n = int(input())

sum = 0
for i in range(n):
    if (i+1) % 3 != 0 and (i+1) % 5 != 0:
        sum += i + 1

print(sum)

Solution (Python):
n = int(input())

sum = 0
for i in range(n):
    nn = i + 1
    if nn % 3 == 0:
        continue
    if nn % 5 == 0:
        continue
    sum += nn

print(sum)

Solution (Python):

n=int(input())
a=[]







for i in range(1,10**6+1):
    if i%15==0:
        a.append("z")
    elif i%3==0:
        a.append("z")
    elif i%5==0:
        a.append("z")
    else:
        a.append(i)

        
ans=0
for i in range(n):
    if a[i]!="z":
        ans+=a[i]
print(ans)

Solution (Python):
N = int(input())
answer = 0
for i in range(1,N+1):
    if i % 3 != 0 and i % 5 != 0:
        answer +=i
print(answer)

Solution (Python):
print(sum([i if (i%3)*(i%5)>0 else 0 for i in range(int(input())+1)]))

Solution (Python):
tmp = list(range(1,int(input())+1))


res = 0
for i in range(len(tmp)):
    if tmp[i] % 3 != 0 and tmp[i] % 5 != 0 and tmp[i] % 15 != 0:
        res += tmp[i]

print(res)

Solution (Python):
n = int(input())

ans = 0
for i in range(1,n+1):
  if (i % 3 != 0) and (i % 5 !=0)  :
    ans += i

print (ans)

Solution (Python):
N=int(input())
L_prime=[j for j in range(1,N+1) if j%3!=0 and j%5!=0]
print(sum(L_prime))

Solution (Python):
a=int(input())
y=0
for x in range(a):
    x=x+1
    if not x%3==0:
        if not x%5==0:
            y=y+x
print(y)

Solution (Python):
N = int(input())
without_fizzbuzz_sum = 0

for i in range(1, N+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    without_fizzbuzz_sum += i

print(without_fizzbuzz_sum)

Solution (Python):
N = int(input())
cnt = 0
for i in range(1, N + 1):
    if i % 3 != 0 and i % 5 != 0:
        cnt += i
print(cnt)

Solution (Python):
n = int(input())

c = 0

for i in range(1,n+1):
  if i%3 == 0 or i%5 == 0:
    pass
  else:
    c += i

print(c)

Solution (Python):
N = int(input())

ans = 0
for i in range(N):
  ans += i+1

fizz = 0
for i in range(N//3):
  fizz += i+1
fizz = fizz*3

buzz = 0
for i in range(N//5):
  buzz += i+1
buzz = buzz*5

fizzbuzz =0
for i in range(N//15):
  fizzbuzz += i+1
fizzbuzz = fizzbuzz*15

print(ans - fizz - buzz + fizzbuzz)

Solution (Python):
N=int(input())
cnt=0
for i in range(1,N+1):
  if i%3==0 or i%5==0:
    continue
  else:
    cnt+=i

print(cnt)

Solution (Python):
n = int(input())
ans = 0
for i in range(n):
    if (i+1) % 5 != 0 and (i+1) % 3 != 0:
        ans += i + 1
print(ans)

Solution (Python):
from sys import stdin
import sys






N = int(input())
ans = 0
for i in range(N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Solution (Python):
def g(N):
    s=0
    for i in range(N+1):
        if i%5!=0 and i%3!=0:
            s+=i
    return s
N=int(input())
print(g(N))

Solution (Python):
n = int(input())
sum = 0
for i in range (1, n+1):
    if i%3 != 0 and i%5 != 0:
        sum += i
print(sum)

Solution (Python):
n = int(input())
summ = 0
for i in range(1, n + 1):
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        summ += i

print(summ)

Solution (Python):


n = int(input())
ans = 0
for i in range(n):
    if (i+1)%3==0 or (i+1)%5==0:
        continue
    else:
        ans += i+1

print(ans)

Solution (Python):
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""
n=int(input())
s=0
for i in range(n+1):
    if(i%5!=0 and i%3!=0):
        s+=i
print(s)