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-----
15

-----Sample Output-----
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.

Difficulty: introductory

Starter code:

Solutions:
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)


n = int(input())

li = [i for i in range(1,n+1) if i % 3 != 0 ]

sum = 0
for i in li:
    if i % 5 != 0:
        sum += i

print(sum)

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

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

def to_fizzbuzz(number):
    if number % 15 == 0:
        return 'FizzBuzz'

    if number % 3 == 0:
        return 'Fizz'

    if number % 5 == 0:
        return 'Buzz'

    else:
        return str(number)
        # return i

def main():
    N = int(input())
    # this list concludes "FizzBuzz", "Fizz" or "Buzz"
    fblist = []
    for number in range(1, 10**6):
        result = to_fizzbuzz(number)
        fblist.append(result)

    # the list up to N
    n_list = fblist[0:N]
    # this list contains only numbers and up to N

    n_numlist = []

    for s in n_list:
        if s.isdigit() == True:
            n_numlist.append(int(s))

    print(sum(n_numlist))


main()

n = int(input())
a = n //3
a_1 = 3*(a+1)*a//2 
b = n // 5
b_1 = 5*(b+1)*b//2
c = n // 15
c_1 = 15*(c+1)* c//2
print(n*(n+1) // 2 - a_1 - b_1+ c_1)

def main() -> None:
    n = int(input())

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

    print(answer)
    return


def __starting_point():
    main()

__starting_point()

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


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

def __starting_point():

    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)

__starting_point()

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

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

n = int(input())

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

print(ans)


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

n = int(input())
sum = 0

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

print(sum)


N = int(input())

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

print(ans)


n = int(input())
n3 = n // 3
n5 = n // 5
n15 = n // 15
print(((n + 1) * n // 2 - 3 * (1 + n3) * n3 // 2 - 5 * (1 + n5) * n5 // 2 + 15 * (1 + n15) * n15 // 2))


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

n=int(input())
l3 = (n//3)*3
l5= (n//5)*5
l15=(n//15)*15
print(n*(n+1)//2 - (3+l3)*l3//6 - (5+l5)*l5//10 + (15+l15)*l15//30  )

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()

n = int(input())

l = []
for i in range(1,n+1):
    if i % 5 == 0 :
        continue
    elif i % 3 == 0:
        continue
    else :
        l.append(i)

print(sum(l))

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

n = int(input())
res = 0
for i in range(1,n+1):
    if(i % 15 ==0): continue
    elif(i % 3 ==0): continue
    elif(i % 5 ==0): continue
    else: res+=i
print(res)

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


N = int(input())
print(sum(map(lambda x:x if (x % 3 != 0) and (x % 5 != 0) else 0,list(range(N + 1)))))

N = int(input())

ls = [i for i in range(1, N+1) if not (i%3==0 or i%5==0)]

print(sum(ls))

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

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


N = int(input())
answer = 0

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

print(answer)

# 入力
n = int(input())

# 処理
sum = 0

for i in range(1, n + 1):
    if i % 15 == 0:
        i = 'FizzBuzz'
    elif i % 3 == 0:
        i = 'Fizz'
    elif i % 5 == 0:
        i = 'Buzz'
    else:
        sum += i

print(sum)

n = int(input())

ans = 0

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

print(ans)



print(sum([i,0][i%3==0 or i%5==0] for i in range(1,int(input())+1)))

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)


n=int(input())
print(sum([x for x in range(1,n+1) if x%3!=0 and x%5!=0]))

N = int(input())
result = 0
for i in range(1, (N + 1)):
    if i % 15 == 0:
        'Fizz Buzz'
    elif i % 3 == 0:
        'Fizz'
    elif i % 5 == 0:
        'Buzz'
    else:
        result = result + i
print(result)

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


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

def sum(n):
  return (n*(n+1))//2

N=int(input())
fizz_cnt=N//3
buzz_cnt=N//5
fizzbuzz_cnt=N//15
print(sum(N)-sum(fizz_cnt)*3-sum(buzz_cnt)*5+sum(fizzbuzz_cnt)*15)

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

n=int(input())
out = n*(n+1)//2
u =n//5
out -= u*(u+1)//2*5
u =n//3
out -= u*(u+1)//2*3
u =n//15
out += u*(u+1)//2*15
print(out)

n = int(input())

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


n = int(input())
total = 0

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

print(total)

import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

n = int(input())

tmp = 0
res = 0

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

print(res)


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

print(ans)

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

ans = sum(fb_list)
print(ans)


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

n=int(input())
a=[0]*(n+1)
for i in range(n+1):
    if i%3==0 or i%5==0:
        a[i]=0
    else:
        a[i]=i
print(sum(a))

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



import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())

    res = 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:
            res += i
    print(res)


def __starting_point():
    resolve()

__starting_point()

N = int(input())
result = 0
for i in range(1, (N + 1)):
    if i % 15 == 0:
        'Fizz Buzz'
    elif i % 3 == 0:
        'Fizz'
    elif i % 5 == 0:
        'Buzz'
    else:
        result = result + i
print(result)

def fizzBuzzSum(n: int) -> int:
    sum = 0
    for i in range(1, n+1):
        if i % 3 != 0 and i % 5 != 0:
            sum += i
    return sum


n = int(input())
print(fizzBuzzSum(n))

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

def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7

#import numpy as np
import sys
import math
import collections

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

N=int(input())

sum=0
i=1
while i<=N:
    if i%3!=0 and i%5!=0:
        sum=sum+i
    i=i+1

print(sum)


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

N =int(input())
a = ""
sum = 0
for i in range(N+1):
#  if(i%15 == 0): a = "FizzBuzz"
  if(i%3 == 0): a ="Fizz"
  elif(i%5 == 0): a = "Buzz"
  else:
    sum =  sum + i
print(sum)

n = int(input())

def main(i):
  if i % 5 == 0 and i % 3 == 0:
    return 0
  elif i % 3 == 0:
    return 0
  elif i % 5 == 0:
    return 0
  else:
    return i
ans = 0
for i in range(n+1):
  ans += main(i)
print(ans)

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

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

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

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

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

n = int(input())

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

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

n = int(input())

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

print(ans)


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

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)


number = int(input())

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

print(ans)


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)

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

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


def __starting_point():
    print((main()))

__starting_point()

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

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

N = int(input())
list = []
for i in range(1, N + 1):
    if i % 3 == 0 and i % 5 == 0:
        "FizzBuzz"
    elif i % 3 == 0:
        "Fizz"
    elif i % 5 == 0:
        "Buzz"
    else:
        list.append(i)
print(sum(list))

def sum(n):
  return (n*(n+1))//2
N=int(input())
fizz_cnt=N//3
buzz_cnt=N//5
fizzbuzz_cnt=N//15
print(sum(N)-sum(fizz_cnt)*3-sum(buzz_cnt)*5+sum(fizzbuzz_cnt)*15)

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

N = int(input())

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

n = int( input() )

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

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

N = int(input())
N_ = [i for i in range(N + 1)]
N3 = [3 * i for i in range(N // 3 + 1)]
N5 = [5 * i for i in range(N // 5 + 1)]
N15 = [15 * i for i in range(N // 15 + 1)]
print((sum(N_) - sum(N3) - sum(N5) + sum(N15)))
return


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

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)

from sys import stdin,stdout

def main():
    n = int(stdin.readline().rstrip())
    ans = 0
    for number in range(1,n+1):
        if((number % 3 != 0) and (number % 5 != 0) ):
            ans = ans + number
    stdout.write(str(ans))
    stdout.write('\n')

main()


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

n = int(input())
l = []
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:
    l.append(i)
print(sum(l))

def readinput():
    n=int(input())
    return n

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

def __starting_point():
    n=readinput()
    ans=main(n)
    print(ans)

__starting_point()

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

n = int(input())
n3 = n // 3

n5 = n // 5
n15 = n // 15

ans = (n+1)*n//2 - (3 + 3*n3)*n3//2 - (5 + 5*n5)*n5//2 +(15 + 15*n15)*n15//2

print(ans)

N = int(input())
ans = 0

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

print(ans)

N=int(input())
L=list(range(1,N+1))
M=list(filter(lambda n:n%3!=0 and n%5!=0,L))
print(sum(M))

N = int(input())

answer = 0

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

print(answer)

print(sum(i for i in range(int(input())+1)if i%3*i%5))

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


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)

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


N = int(input())

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

print(fizzbuzz_sum)

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

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


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)


N = int(input())

cnt = 0
for i in range(N+1):
    if i % 15 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        cnt += i

print(cnt)