CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))
sum = 0

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

print(sum)

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

def isnot_fizzbuzz(number: int) -> bool:
    if (number) % 3 != 0 and (number) % 5 != 0:
        return True
    return False

def main():
    sum = 0
    for number in range(1, N + 1):
        if isnot_fizzbuzz(number) == True:
            sum += number
    print(sum)

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

# 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
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))

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

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

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

    print(ans)

if __name__ == '__main__':
    solve()


# Optimized solution
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(eval(input()))
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print((k.join(list(map(str, lst)))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

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

if __name__ == '__main__':
    solve()
# Original solution
n = int(eval(input()))

fizzbuzz = 0
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()))

n15 = n // 15
n5 = n // 5
n3 = n // 3

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

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

ans = 0

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

print(ans)


# Optimized solution
from functools import lru_cache

N = int(eval(input()))
 
@lru_cache(maxsize=1000)
def main(K):
    ans = 0
    for i in range(1, N+1):
        if i % 15 != 0 and i % 3 != 0 and i % 5 != 0:
            ans = ans + i
    return(ans)
 
print((main(N)))
# Original solution
N = int(eval(input()))
list = []
for i in range(1,N+1):
    list.append(i)
for i in range(1,(N+3)//3):
    list[3*i-1] = 0
for i in range(1,(N+5)//5):
    list[5*i-1] = 0
print((sum(list)))

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

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

ans = 0
for i in range(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(N+1):
    if i%3!=0 and i%5!=0 :
        ans += i
print(ans)
# Original solution
N = int(eval(input()))
FizzBuzz = []
Fizz = []
Buzz = []
ano = []
plus = 0
for i in range(N+1):
    if i % 3 == 0 and i % 5 == 0:
        FizzBuzz.append(i)
    elif i % 3 == 0:
        Fizz.append(i)
    elif i % 5 == 0:
        Buzz.append(i)
    else:
        ano.append(i)
for a in ano:
    plus += a

print(plus)

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

# Optimized solution
K = int(eval(input()))
x = (K+1) * K//2
num_devisible_three = (3+3*(K//3))*(K//3)//2
num_devisible_five = (5+5*(K//5))*(K//5)//2
num_devisible_fifteen = (15+15*(K//15))*(K//15)//2
print((x-num_devisible_three-num_devisible_five+num_devisible_fifteen))
# Original solution
N = int(eval(input()))
total = 0
for i in range(1, N + 1):
    if i % 3 != 0 and i % 5 != 0:
        total += i
print(total)

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

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

# 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 for i in range(int(eval(input()))+1) if i%3!=0 and i%5!=0)))

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

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

print(ans)

# Optimized solution
N = int(eval(input()))
N3 = N//3
N5 = N//5
N15 = N//15

ans = N*(N+1)/2 - 3*N3*(N3+1)/2 -5*N5*(N5+1)/2 + 15*N15*(N15+1)/2

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

# Optimized solution
n=int(eval(input()))
a=[0,1,3,3,7,7,7,14,22,22,22,33,33,46,60]
b=[0,1,1,0,1,0,0,1,1,0,0,1,0,1,1]
print((60*(n//15)+120*(n//15)*(n//15-1)//2+sum(b[:n%15+1])*(15*(n//15))+a[n%15]))
# Original solution
n = int(eval(input()))  #スペース抜きの複数行,１文字ずつ
A = []

for i in range(1, n + 1):
    if i % 15 == 0:
        A.append(0)
    elif i % 3 == 0:
        A.append(0)
    elif i % 5 == 0:
        A.append(0)
    else:
        A.append(i)

print((sum(A)))

# Optimized solution
N = int(eval(input()))  #スペース抜きの複数行,１文字ずつ
 
A = []
for i in range(1,N+1):
  if i % 3 == 0:
    A.append(0)
  elif i % 5 == 0:
    A.append(0)
  else:
    A.append(i)

print((sum(A)))
# Original solution
N = int(eval(input()))  #スペース抜きの複数行,１文字ずつ
 
A = []
for i in range(1,N+1):
  if i % 3 == 0:
    A.append(0)
  elif i % 5 == 0:
    A.append(0)
  else:
    A.append(i)

print((sum(A)))

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

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

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

# Optimized solution
n = int(eval(input()))
ans = 0
for i in range(n+1):
  if i%3 != 0 and i%5 != 0:
    ans = ans + i
print(ans)
# Original solution
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print(('\n'.join(map(str, x))))

N = int(eval(input()))

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




# Optimized solution
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print(('\n'.join(map(str, x))))

N = int(eval(input()))

cnt = 0
for i in range(1, N+1):
    if i%3==0 or i%5==0:
        pass
    else:
        cnt += i
print(cnt)
# Original solution
n = int(eval(input()))
sum = 0
for i in range(1,n+1):
    if not(i%15==0 or i%5==0 or i%3==0):
        sum += i
print(sum)

# Optimized solution
n = int(eval(input()))
print((sum(i for i in range(1,n+1) if i%5!=0 and i%3!=0 if i%15 != 0)))
# Original 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)

# Optimized solution
N = int(eval(input()))
total = int(1/2 * N *  (N+1))
wa3 =  (N//3 * (N//3 + 1)) // 2 * 3
wa5 =  (N//5 * (N//5 + 1)) // 2 * 5
wa15 =  (N//15 * (N//15 + 1)) // 2 * 15
print((total - wa3 - wa5 + wa15))
# Original solution
print((sum(set(i for i in range(1,int(eval(input()))+1,1) if not(i%3==0 or i%5==0)))))

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

print(sum)

# Optimized solution
#-*- coding: utf-8 -*-
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()))

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


print(count)


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

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


print(count)
# Original solution
N=int(eval(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)

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

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


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


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

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


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

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


# Optimized solution
N = int(eval(input()))
l = [i for i in range(1, N + 1)]

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

# Optimized solution
N = int(eval(input()))
ans = int(N * (N + 1) / 2 - (N // 3) * (N // 3 + 1) / 2 * 3 - (N // 5) * (N // 5 + 1) / 2 * 5 + (N // 15) * (N // 15 + 1) / 2 * 15)
print(ans)
# Original solution
n=int(eval(input()))
ans=0
def fb(num):
    if num%3==0 or num%5==0:
        return False 
    else:
        return True
for i in range(1,n+1):
    if fb(i):
        ans+=i
print(ans)



# Optimized solution
n=int(eval(input()))
def func():
    s=0
    for i in range(1,n+1):
        if not(i%3==0 or i%5==0):
            s+=i
        else:
            continue 
    return s
print((func()))
# Original solution
n = int(eval(input()))
ans = 0
for i in range(n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

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

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

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

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

# Optimized solution
print((sum(n for n in range(1+int(eval(input()))) if n%3 and n%5)))
# Original solution
N=int(eval(input()))
s=0
for i in range(1,N+1):
    if i%15==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()))
answer = 0

for i in range(1, n + 1):       # range内を出力(i)していく
    if i % 3 != 0 and i % 5 != 0:
        answer += i             # iを足していったものがanswer
print(answer)                   # 実際に見えるように出力
# Original solution
n = int(eval(input()))
ans = 0
for i in range(1,n+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    ans += i
print(ans)


# Optimized solution
N = int(eval(input()))
#A = list(map(int, input().split()))
amount = (N+1) * N // 2
three = N // 3
three = (three + 1) * 3 * three // 2 if three > 0 else 0
five = N // 5
five = (five + 1) * 5 * five // 2 if five > 0 else 0
fifteen = N // 15
fifteen = (fifteen + 1) * 15 * fifteen // 2 if fifteen > 0 else 0
print((amount-three-five+fifteen))
# Original solution
n = int(eval(input()))

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

# 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
def solve(n):
    ans = 0
    for i in range(1, n+1):
        if (i % 3 == 0 and i % 5 == 0) or (i % 3 == 0) or (i % 5 == 0):
            continue
        else:
            ans += i
    print(ans)

if __name__ == "__main__":
    n = int(eval(input()))
    solve(n)

# Optimized solution
def solve(n):
    arr = [i for i in range(1, n+1) if i % 3 != 0 and i % 5 != 0]
    print((sum(arr)))

if __name__ == "__main__":
    n = int(eval(input()))
    solve(n)
# Original solution
N = int(eval(input()))
total = 0
for i in range(1, N+1):
    if (i % 3) != 0 and (i % 5) != 0:
        total = total+i
print(total)

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

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

print(ans)


# Optimized solution
N = int(eval(input()))
ans = []

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

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

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

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

print((sum(a)))



# Optimized solution
# 別解法　o(1)
def gauss(n):
    return n * (n+1) // 2

n = int(eval(input()))
ans =  gauss(n) - gauss(n//3) * 3 - gauss(n//5) * 5 + gauss(n//15) * 15

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

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

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

a = [0] * N

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:
        a[i-1] = i

print((sum(a)))

# Optimized 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)
# Original solution
n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    ans += i
print(ans)


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

total = {}
for i in (1, 3, 5, 15):
    total[i] = i * (n // i) * (n // i + 1) // 2

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

print(ans)

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

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

if __name__ == "__main__":
    main()

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

if __name__ == "__main__":
    main()
# Original solution
s = 0
for i in range(1, int(eval(input()))+1):
    if i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        s += i

print(s)

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


# Optimized solution
import math
N = int(eval(input()))
S = int(N*(N+1)/2)
S -= 3*int(math.floor(N/3)*(math.floor(N/3)+1)/2)
S -= 5*int(math.floor(N/5)*(math.floor(N/5)+1)/2)
S += 15*int(math.floor(N/15)*(math.floor(N/15)+1)/2)
print(S)
# Original solution
n = int(eval(input()))
A = list(range(1, n+1))
B = list()
for i in range(1, n+1):
    if i % 5 == 0 or i % 3 == 0:
        B.append(i)
ans = list(set(A) - set(B))
print((sum(ans)))

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

n3 = n // 3
n5 = n // 5
n15 = n // 15

print((n*(n + 1)//2 - 3*n3*(n3 + 1)//2 - 5*n5*(n5 + 1)//2 + 15*n15*(n15 + 1)//2))
# Original 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)

# 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()))
A = []
for i in range(N+1):
    if i % 15 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        A.append(i)
print((sum(A)))

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


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

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

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


# Optimized solution
n = int(eval(input()))
ans = 0
for i in range(n+1):
  if i%3!=0 and i%5!=0:
       ans = ans + i
print(ans)
# Original solution
primes = [0, 0] + [1] * 9999
for i in range(2, 101):
    if primes[i]:
        for j in range(i*i, 10001, i):
            primes[j] = 0

while True:
    try:
        N = int(eval(input()))
    except:
        break
    print((sum(primes[i] & primes[N-i+1] for i in range(1, N+1))))

# Optimized solution
primes = [0, 0] + [1] * 9999
for i in range(2, 101):
    if primes[i]:
        for j in range(i*i, 10001, i):
            primes[j] = 0

while True:
    try:
        N = int(eval(input()))
    except:
        break
    print((sum(primes[i] and primes[N-i+1] for i in range(1, N+1))))
# Original solution
import math
r = 9999
sqrt = int(math.sqrt(r))
p = [1 for i in range(r)]
p[0] = 0
for i in range(sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for j in range(2*i+1,r,i+1)]
prime = []
for i in range(r):
    if p[i]:
        prime.append(i)

while True:
    try:
        n = int(input())
        count = 0
        for i in prime:
            if i > n-1:
                break
            if p[i]*p[n-i-1] == 1:
                count += 1
        print(count)
    except:
        break

# Optimized solution
import math
r = 9999
sqrt = int(math.sqrt(r))
p = [1 for i in range(r)]
p[0] = 0
for i in range(sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for j in range(2*i+1,r,i+1)]
prime = []
for i in range(r):
    if p[i]:
        prime.append(i)

while True:
    try:
        n = int(input())
        count = 0
        for i in prime:
            if i > n-1:
                break
            if p[n-i-1] == 1:
                count += 1
        print(count)
    except:
        break
# Original solution
def prime_table(n):
    list = [True for _ in range(n + 1)]
    i = 2
    while i * i <= n:
        if list[i]:
            j = i + i
        while j <= n:
            list[j] = False
            j += i
        i += 1

    table = [i for i in range(n + 1) if list[i] and i >= 2]
    return table

table = prime_table(10000)
while True:
    try:
        n = int(input())
    except EOFError:
        break
    
    l = (i for i in range(1,n+1))
    r = (i for i in range(n,0,-1))
    ans = 0
    for j,k in zip(l,r):
        if j in table and k in table:
            ans += 1
    print(ans)

# Optimized solution
def prime_table_boolean(n):
    list1 = [True for _ in range(n + 1)]
    i = 2
    while i * i <= n:
        if list1[i]:
            j = i + i
        while j <= n:
            list1[j] = False
            j += i
        i += 1
    list1[1] = False
    del list1[0]

    #table = [i for i in xrange(n + 1) if list1[i] and i >= 2]
    #return table
    return list1

table = prime_table_boolean(10001)
while True:
    try:
        n = int(input())
    except EOFError:
        break
    
    l = table[:n]
    r = l[::-1]
    ans = 0
    for j,k in zip(l,r):
        if j and k:
            ans += 1
    print(ans)