CodeEff/ECCO huggingface dataset:
# Original solution
import heapq
from collections import defaultdict
v_num = int(eval(input()))
edges = defaultdict(list)
for i in range(v_num):
    data = [int(n) for n in input().split(" ")[1:]]
    for j in range(i + 1, v_num):
        if data[j] != -1:
            edges[i].append([data[j], j])
            edges[j].append([data[j], i])
queue = []
heapq.heapify(queue)
for c in edges[0]:
    heapq.heappush(queue, c)
visited = {0}
answer = 0
while len(visited) < v_num:
    q = heapq.heappop(queue)
    weight, one = q[0], q[1]
    if one in visited:
        continue
    answer += weight
    for e in edges[one]:
        heapq.heappush(queue, e)
    visited |= {one}
print(answer)

# Optimized solution
import heapq
from collections import defaultdict
v_num = int(eval(input()))
edges = defaultdict(list)
for i in range(v_num):
    data = [int(n) for n in input().split(" ")[1:]]
    for j in range(i + 1, v_num):
        if data[j] != -1:
            edges[i].append([data[j], j])
            edges[j].append([data[j], i])
queue = []
heapq.heapify(queue)
for c in edges[0]:
    heapq.heappush(queue, c)
visited = {0}
answer = 0
while len(visited) < v_num:
    q = heapq.heappop(queue)
    weight, one = q[0], q[1]
    if one in visited:
        continue
    answer += weight
    for e in edges[one]:
        if e[1] not in visited:
            heapq.heappush(queue, e)
    visited |= {one}
print(answer)
# Original solution
n = int(eval(input()))
edgeArray = [list(map(int, input().split())) for i in range(n)]
edgeList = []
rootList = [-1 for i in range(n)]
sumLength = 0

def getRoot(x):
    r = rootList[x]
    if r < 0:
        rootList[x] = x
    elif r != x:
        rootList[x] = getRoot(r)
    return rootList[x]
        
for i in range(n):
    for j in range(i):
        if edgeArray[i][j] != -1:
            edgeList.append([edgeArray[i][j], i, j])
edgeList.sort(key=lambda x: x[0])
for e in edgeList:
    x = getRoot(e[1])
    y = getRoot(e[2])
    if x != y:
        sumLength += e[0]
        rootList[x] = rootList[y] = min(x, y)
print(sumLength)

# Optimized solution
n = int(eval(input()))
edgeList = []
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(i):
        if a[j] != -1:
            edgeList.append([a[j], i, j])
rootList = [-1 for i in range(n)]
sumLength = 0

def getRoot(x):
    r = rootList[x]
    if r < 0:
        rootList[x] = x
    elif r != x:
        rootList[x] = getRoot(r)
    return rootList[x]
        

edgeList.sort(key=lambda x: x[0])
for e in edgeList:
    x = getRoot(e[1])
    y = getRoot(e[2])
    if x != y:
        sumLength += e[0]
        rootList[x] = rootList[y] = min(x, y)
print(sumLength)
# Original solution
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    inf = float('inf')
    n = int(input())
    a = []

    for i in range(n):
        line = [int(i) for i in input().split()]
        line = [i if i != -1 else inf for i in line]
        a.append(line)

    
    checked = [False] * n
    d = [inf] * n
    d[0] = 0
    checked[0] = True
    ans = 0
    nxt = 0

    for i in range(n - 1):
        for j in range(n):
            if a[nxt][j] < d[j]:
                d[j] = a[nxt][j]

        min_w = inf
        min_n = 0

        for j in range(n):
            if not checked[j] and d[j] < min_w:
                min_n = j
                min_w = d[j]

        checked[min_n] = True
        nxt = min_n
        ans += min_w

    # debug(d, locals())
    print(ans)



if __name__ == '__main__':
    solve()


# Optimized solution
import sys

inf = float('inf')

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def prim(n, As):
    checked = [False] * n
    d = [inf] * n
    checked[0] = True
    d[0] = 0
    nxt = 0
    tot_wgt = 0

    for i in range(n - 1):
        for j in range(n):
            if As[nxt][j] < d[j]:
                d[j] = As[nxt][j]

        min_w = inf
        min_n = 0
        for j in range(n):
            if not checked[j] and min_w > d[j]:
                min_w = d[j]
                min_n = j

        tot_wgt += min_w
        nxt = min_n
        checked[nxt] = True

    return tot_wgt

def solve():
    n = int(input())
    As = []

    for i in range(n):
        line = [int(j) for j in input().split()]
        As.append([i if i != -1 else inf for i in line])

    ans = prim(n, As)

    print(ans)


if __name__ == '__main__':
    solve()
# Original solution
print((input().count("o")*100+700))

# Optimized solution
print(((input().count("o")+7)*100))
# Original solution
#                         author:  kagemeka 
#                         created: 2019-11-07 12:33:44(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    s = sys.stdin.readline().rstrip()
    ans = 700 + 100 * s.count('o')
    print(ans)



if __name__ == "__main__":
    # execute only if run as a script
    main()


# Optimized solution
import sys

s = sys.stdin.readline().rstrip()

def main():
    return 700 + 100 * s.count('o')

if __name__ == '__main__':
    ans = main()
    print(ans)
# Original solution
print((700+100*int(input().count("o"))))

# Optimized solution
print((700+100*input().count("o")))
# Original solution
print((700 + input().count('o') * 100))

# Optimized solution
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
answer = 700 + 100 * S.count('o')
print(answer)
# Original solution
print((700+100*(input().count("o"))))

# Optimized solution
print((700+100*input().count("o")))
# Original solution
print((700+input().count("o")*100))

# Optimized solution
print(([7,8,9,10][input().count("o")]*100))
# Original solution
N = int(eval(input()))

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


print(ans)

# Optimized solution
N = int(eval(input()))

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


print(ans)
# Original solution
N = int(eval(input()))
num = []
for i in range(1, N+1):
  if i % 3 == 5 and i % 5 == 0:
    continue
  elif i % 3 == 0:
    continue
  elif i % 5 == 0:
    continue
  num.append(i)
print((sum(num)))

# Optimized solution
print((sum([i for i in range(1,int(eval(input()))+1) if not ((i%3==0 and i%5==0) or i%3==0 or i%5==0)])))
# Original solution
print((sum([i for i in range(1,int(eval(input()))+1) if not ((i%3==0 and i%5==0) or i%3==0 or i%5==0)])))

# Optimized solution
print((sum([i for i in range(1,int(eval(input()))+1) if i%15 and i%5 and i%3])))
# Original solution
n = int(eval(input()))

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

print((sum(l)))

# Optimized solution
n = int(eval(input()))

l = 0
for i in range(1,n+1):
  if i % 3 == 0 or i % 5 == 0:
    continue
  else:
    l+=i
print(l)
# Original solution
n = int(eval(input()))

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

print(ans)

# Optimized solution
n = int(eval(input()))

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

print(ans)
# Original solution
N = int(eval(input()))
S =0
for i in range(N+1):
    if (i%3==0) and (i%5==0):
        S = S 
    elif i%3==0:
        S = S
    elif i%5==0:
        S = S
    else:
        S = S + i
print(S)

# Optimized solution
N = int(eval(input()))
S =0
for i in range(1, N+1):
    if (i%3==0) and (i%5==0):
        S = S 
    elif i%3==0:
        S = S
    elif i%5==0:
        S = S
    else:
        S = S + i
print(S)
# Original solution
def solve(string):
    return str(sum(i for i in range(int(string) + 1) if i % 3 > 0 and i % 5 > 0))


if __name__ == '__main__':
    import sys
    print((solve(sys.stdin.read().strip())))


# Optimized solution
def solve(string):
    n = int(string)

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

    return str(f(n) - 3 * f(n // 3) - 5 * f(n // 5) + 15 * f(n // 15))


if __name__ == '__main__':
    import sys
    print((solve(sys.stdin.read().strip())))
# Original solution
from collections import *

N = int(eval(input()))
ans = 0

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

print(ans)

# Optimized solution
N = int(eval(input()))
ans = 0

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

print(ans)
# Original solution
N = int(eval(input()))
SUM = []
for i in range(1,N+1):
    if i % 3 == 0 or i % 5 ==0:
        pass
    else:
        SUM.append(i)

print((sum(SUM)))


# Optimized solution
N = int(eval(input()))
count = 0
for i in range(1,N+1):
  if not(i % 3== 0 or i % 5 == 0):
    count += i
print(count)
# Original solution
x = int(eval(input()))
ans = 0

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

print(ans)

# Optimized solution
x = int(eval(input()))
ans = 0

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

a = [0 for i in range(n)]

count = 0

for i in range(n):
  if (i+1)%3 == 0 or (i+1)%5 == 0:
    continue
  else:
    a[i] = (i+1)
    count += (i+1)

print(count)

# Optimized solution
n = int(eval(input()))

count = 0

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

print(count)
# Original solution
n = int(eval(input()))

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

print((sum(a)))

# Optimized solution
n = int(eval(input()))
a= [i for i in range(1, n+1) 
   if i % 3 != 0 and i % 5 != 0 and i % 15 != 0]
print((sum(a)))
# Original solution
N = int(eval(input()))
sm = 0
for x in range(N+1):
    if x % 3 and x % 5:
        sm += x
print(sm)

# Optimized solution
s=lambda x:x*(x+1)//2;print((s(n:=int(eval(input())))-s(n//3)*3-s(n//5)*5+s(n//15)*15))
# Original solution
n=int(eval(input()))
cnt=0
for i in range(1,n+1):
    if (i%3==0 or i%5==0):
        continue
    else: cnt+=i
print(cnt)

# Optimized solution
print((sum(i for i in range(int(eval(input()))+1) if i %3 !=0 and i%5!=0)))
# Original solution
print((sum(i*(min(i%5,i%3)!=0)for i in range(int(eval(input()))+1))))

# Optimized solution
print((sum(i*(i%5>0<i%3)for i in range(int(eval(input()))+1))))
# Original solution
n = int(eval(input()))
a = 0
for i in range(1,n+1):
    if not(i % 3 == 0 or i % 5 == 0):
        a += i
print(a)

# Optimized solution
#!/usr/bin/env python3
n = int(eval(input()))
a = 0
for i in range(1,n+1):
    if not(i % 3 == 0 or i % 5 == 0):
        a += i
print(a)
# Original solution
n = int(eval(input()))
ans = 0
for i in range(1, n+1):
    if not (i % 3 == 0 or i % 5 == 0):
        ans += i

print(ans)

# Optimized solution
def main():
    n = int(eval(input()))
    ans = 0
    for i in range(1, n+1):
        if not (i % 3 == 0 or i % 5 == 0):
            ans += i

    print(ans)

if __name__ == "__main__":
    main()
# Original solution
N = eval(input())
count :int=0
for k in range(int(N)):
  if (k+1)%3!=0 and (k+1)%5!=0:
    count+=(k+1)
print(count)

# Optimized solution
n=int(eval(input()))
ans=0
for i in range(1,n+1):
  if i%3!=0 and i%5!=0:
    ans+=i
print(ans)
# Original solution
n=int(eval(input()))
n=list(range(1,n+1))
n=([i for i in n if i % 3 != 0])
n=([i for i in n if i % 5 != 0])
print((sum(n)))

# Optimized solution
n=int(eval(input()))
n=list(range(1,n+1))
n=([i for i in n if i % 3 != 0 and i % 5 != 0])
print((sum(n)))
# Original solution
N = int(eval(input()))

def fizz_buzz(n):
  return 0 if n % 5 == 0 or n % 3 == 0 else n

print((sum(
  fizz_buzz(i)
  for i in range(1, N + 1)
)))

# Optimized solution
N = int(eval(input()))

print((sum(
  i
  for i in range(1, N + 1)
  if i % 3 != 0 and i % 5 != 0
)))
# Original solution
N = int(input().rstrip())
ret = 0
for i in range(1, N+1):
    if i%3==0 or i%5==0:
        continue
    else:
        ret += i
print(ret)


# Optimized solution
print((sum(list(i for i in range(int(eval(input()))+1) if i%3 > 0 < i%5))))
# Original solution
N=int(eval(input()))

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

# Optimized solution
N=int(eval(input()))
sum=0
for i in range(N+1):
    if i%3==0 or i%5==0:
        sum+=0
    else:
        sum+=i
print(sum)
# Original solution
n = int(eval(input()))
s3 = 0
s5 = 0
s15 = 0
count = 0
for i in range(int(n / 3)):
    s3 += (i+1) * 3
for i in range(int(n / 5)):
    s5 += (i + 1) * 5
for i in range(int(n / 15)):
    s15 += (i + 1) * 15
for i in range(n):
    count += (i+1)
print((count-s3-s5+s15))

# Optimized solution
n = int(eval(input()))
Sum = 0.5 * n * (1 + n)
# n < 3やn < 5のときでもint(n/3) = int(n/5) = 0のため問題なし
Sum3_5 = 0.5*(int(n/3)*(3+3*int(n/3))+int(n/5)*(5 + 5*int(n/5)))
Sum15 = 0.5 * (int(n / 15) * (15 + int(n / 15) * 15))
# 問題の回答が整数値のため
print((int(Sum-Sum3_5+Sum15)))
# Original solution
n = int(eval(input()))

num = [i for i in range(1, n + 1)]
for i in range(n):
    if (num[i] % 3 == 0) or (num[i] % 5 == 0):
        num[i] = 0

print((sum(num)))


# Optimized solution
n = int(eval(input()))

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

print(cnt)
# Original solution
import sys
input = sys.stdin.readline


def fizzbuzz(n):
    if n % 5 == 0 and n % 3 == 0:
        return 0
    elif n % 3 == 0:
        return 0
    elif n % 5 == 0:
        return 0
    else:
        return n


def main():
    n = int(eval(input()))
    li = list(range(1, n+1))

    change_li = list(map(fizzbuzz, li))

    print((sum(change_li)))


if __name__ == '__main__':
    main()


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

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

# Optimized solution
n = int(eval(input()))
l = [i for i in range(1,n+1) if i%3 != 0 and i%5 != 0]
print((sum(l)))
# Original solution
import sys

n = int(sys.stdin.readline().rstrip())

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

if __name__ ==  '__main__':
    main()

# Optimized solution
import sys

n = int(sys.stdin.readline().rstrip())

def main():
    ans = sum([x for x in range(1, n + 1) if x % 3 and x % 5])
    print(ans)

if __name__ ==  '__main__':
    main()
# Original solution
N=int(eval(input()))
sum=0
for i in range(1, N+1):
    if (not i%3==0) and (not i%5==0):
        sum+=i
print(sum)

# Optimized solution
def sum(n):
    return n*(n+1)//2
N=int(eval(input()))
print((sum(N)-sum(N//3)*3-sum(N//5)*5+sum(N//15)*15))
# Original solution
N = int(eval(input()))
sum = 0
for i in range(1, N+1):
  if i % 3 != 0 and i % 5 != 0:
    sum += i
print(sum)

# Optimized solution
N = int(eval(input()))

Ndiv3 = N // 3
Ndiv5 = N // 5
Ndiv15 = N // 15

ans = (N*(N + 1) - 3*Ndiv3*(Ndiv3 + 1) - 5*Ndiv5*(Ndiv5 + 1) + 15*Ndiv15*(Ndiv15 + 1))//2
print(ans)
# Original solution
# 入力N
N = int(eval(input()))

ary = list(range(1, N + 1, 1))
ary2 = []

for x in ary:
    if x % 3 != 0 and x % 5 != 0:
        ary2.append(x)

print((sum(ary2)))

# Optimized solution
# 入力N
N = int(eval(input()))

ary2 = []

for x in list(range(1, N + 1, 1)):
    if x % 3 != 0 and x % 5 != 0:
        ary2.append(x)

print((sum(ary2)))
# Original solution
# 入力N
N = int(eval(input()))

ary2 = []

for x in list(range(1, N + 1, 1)):
    if x % 3 != 0 and x % 5 != 0:
        ary2.append(x)

print((sum(ary2)))

# Optimized solution
# 入力N
N = int(eval(input()))

ans = 0

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

print(ans)
# Original solution
n = int(eval(input()))
a = []
for i in range(1,n+1):
    a.append(i)
new_a = [i for i in a if  i%3 != 0 and i%5 != 0]
print((sum(new_a)))

# Optimized solution
n = int(eval(input()))
a = list(range(1,n+1))
new_a = [i for i in a if  i%3 != 0 and i%5 != 0]
print((sum(new_a)))
# Original solution
a = int(eval(input()))
sum = 0
list_number = []
for i in range(a):
    list_number.append(i + 1)
for i in list_number:
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        sum = sum + i
print(sum)

# Optimized solution
n = int(eval(input()))
sum = 0
for i in range(1, n+1):
    if i % 3 != 0 and i % 5 != 0:
        sum += i
print(sum)
# Original solution
N = int(eval(input()))

amount = 0

for i in range(1, N + 1):
    if (i % 15 == 0) or (i % 3 == 0) or (i % 5 == 0):
        pass
    else:
        amount = amount + i

print(amount)


# Optimized solution
N = int(eval(input()))

amount = 0

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

    if not is_fizzbuzz:
        amount += i

print(amount)
# Original solution
N = int(eval(input()))

amount = 0

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

    if not is_fizzbuzz:
        amount += i

print(amount)


# Optimized solution
n = int(eval(input()))
summation = 0

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

print(summation)
# Original solution
N = eval(input())
Q = 0
for i in range(int(N)+1):
  P = []
  for j in range(len(str(i))):
    k= str(i)
    P.append(int(k[j]))
  if(sum(P)%3 == 0 or P[-1]%5 == 0):
      Q += 0
  else:
      Q += i
print(Q)

# Optimized solution
N = int(eval(input()))
Q = 0
for i in range(1,N+1):
  if(i%3 != 0 and i%5 != 0):
      Q += i
print(Q)
# Original solution
N = int(eval(input()))
ans = 0
for i in range(1, N + 1):
    if i % 5 > 0 and i % 3 > 0:
        ans += i
print(ans)


# Optimized solution
def sum(N):
    return N * (N + 1) // 2


N = int(eval(input()))
print((sum(N) - sum(N // 3) * 3 - sum(N // 5) * 5 + sum(N // 15) * 15))
# Original solution
n = int(eval(input()))
print((sum(i for i in range(1, n + 1) if i % 3 != 0 and i % 5 != 0)))

# Optimized solution
n = int(eval(input()))
print((sum(i for i in range(1, n + 1) if i % 3 and i % 5)))
# Original solution
N = int(eval(input()))
ls = []
for i in range(N+1):
    if i%3==0 or i%5==0:
        pass
    else:
        ls.append(i)
print((sum(ls)))


# Optimized solution

N = int(eval(input()))

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

print(sum_)
# Original solution
n=int(eval(input()))
sum=0
for i in range(1,n+1):
    if(i%15!=0 and i%3!=0 and i%5!=0 ):
        sum=sum+i
print(sum)

# Optimized solution
n = int(eval(input()))
ans = 0
for i in range(1, n+1):
    if i%3 == 0 or i%5==0:
        pass
    else:
        ans += i
print(ans)
# Original solution
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))

anslist = []

for i in range(1, n+1):
    if (i % 3 == 0) and (i % 5 == 0):
        continue
        # print('FizzBuzz', end=' ')
    elif i % 3 == 0:
        continue
        # print('Fizz', end=' ')
    elif i % 5 == 0:
        continue
        # print('Buzz', end=' ')
    else:
        anslist.append(i)
        # print(i, end=' ')

print((sum(anslist)))

# Optimized solution
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))

anslist = []

for i in range(1, n+1):
    # print(i)
    if i % 15 == 0:
        continue
        # print('FizzBuzz', end=' ')
    elif i % 3 == 0:
        continue
        # print('Fizz', end=' ')
    elif i % 5 == 0:
        continue
        # print('Buzz', end=' ')
    else:
        anslist.append(i)
        # print(i, end=' ')

print((sum(anslist)))
# Original solution
N = int(eval(input()))
a = 0
for i in range(1, N + 1):
    if i % 5 != 0 and i % 3 != 0:
        a += i
print(a)


# Optimized solution
N = int(eval(input()))
print((sum([i for i in range(1, N+1) if i%5!=0 and i%3!=0])))
# Original solution
N = int(eval(input()))
print((sum([i for i in range(1, N+1) if i%5!=0 and i%3!=0])))

# Optimized solution
k = int(eval(input()))
a = (1 + k) * k // 2
three = (3+3*(k//3)) * (k // 3) // 2
five = (5+5*(k//5)) * (k // 5) // 2
fifteen = (15+15*(k//15)) * (k // 15) // 2
print((a-three-five+fifteen))
# Original solution
from math import floor
N = int(eval(input()))

S = int((N * (N+1)) / 2)

fizz = floor(N/3)
buzz = floor(N/5)
fizzbuzz = floor(N/15)
print((S - int(3 * fizz * (fizz+1)/2) -
          int(5*buzz*(buzz+1) /2) +
          int(15 * fizzbuzz * (fizzbuzz+1)/2)))

# Optimized solution
from math import floor
def sum(x):
    return int(x *(x+1)/2)
N = int(eval(input()))

S = sum(N)

fizz = floor(N/3)
buzz = floor(N/5)
fizzbuzz = floor(N/15)
print((S - 3 * sum(fizz) - 5*sum(buzz) + 15 * sum(fizzbuzz)))
# Original solution
def main():
    n = int(eval(input()))
    s = 0
    for i in range(1, n+1):
        if i % 3 == 0 and i % 5 == 0:
            pass
        elif i%3 == 0:
            pass
        elif i%5 == 0:
            pass 
        else:
            s += i
    print(s)

if __name__ == "__main__":
    main()

# Optimized solution
def main():
    n = int(eval(input()))
    s = 0
    for i in range(1, n+1):
        if not (i % 3 == 0 or i % 5 == 0):
            s += i
    print(s)


if __name__ == "__main__":
    main()
# Original solution
N=int(eval(input()))
ans=0
for i in range(1,N+1):
    if not (i%3==0 or i%5==0):
        ans+=i
print(ans)

# Optimized solution
N=int(eval(input()))
Fizz=list(range(3,N+1,3))
Buzz=list(range(5,N+1,5))
FizzBuzz=list(range(15,N+1,15))
ans=sum(range(1,N+1))-sum(Fizz)-sum(Buzz)+sum(FizzBuzz)
print(ans)
# Original solution
n = int(eval(input()))

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

# Optimized solution
import sys

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


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

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

    print(res)


if __name__ == '__main__':
    resolve()
# Original solution
import sys


def in_ctrl():
    _input = [_.rstrip() for _ in sys.stdin.readlines()]
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    N = int(_input[0])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return N


def out_ctrl(s):
    print(s)


if __name__ == "__main__":
    N = in_ctrl()
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    for n in range(N+1):
        if n%3>0 and n%5>0:
            cnt += n
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    out_ctrl(cnt)

# Optimized solution
from sys import stdin


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


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0]) # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = __sum(N)-3*__sum(N//3)-5*__sum(N//5)+15*__sum(N//15)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
# Original solution
count=0
N=int(eval(input()))
for i in range(N):
	if (i+1)%3==0 and (i+1)%5==0:
		continue
	elif (i+1)%3==0:
		continue
	elif (i+1)%5==0:
		continue
	else:
		count+=(i+1)
print(count)

# Optimized solution
N=int(eval(input()))
ans=0
for i in range(1,N+1):
	if i%3==0 or i%5==0:continue
	else:
		ans+=i
print(ans)
# Original solution
n = int(eval(input()))
us = set(i for i in range(1, n + 1))
m3 = set(i for i in range(3, n + 1, 3))
m5 = set(i for i in range(5, n + 1, 5))
print((sum(list(us - m3 - m5))))

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