A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer.Limak can discard (throw out) some cards. His goal is to minimize the sum of numbers written on remaining (not discarded) cards.He is allowed to at most once discard two or three cards with the same number. Of course, he won't discard cards if it's impossible to choose two or three cards with the same number.Given five numbers written on cards, cay you find the minimum sum of numbers on remaining cards?

The only line of the input contains five integers t1, t2, t3, t4 and t5 (1 ≤ ti ≤ 100) — numbers written on cards.

Print the minimum possible sum of numbers written on remaining cards.

NoteIn the first sample, Limak has cards with numbers 7, 3, 7, 3 and 20. Limak can do one of the following.  Do nothing and the sum would be 7 + 3 + 7 + 3 + 20 = 40.  Remove two cards with a number 7. The remaining sum would be 3 + 3 + 20 = 26.  Remove two cards with a number 3. The remaining sum would be 7 + 7 + 20 = 34. You are asked to minimize the sum so the answer is 26.In the second sample, it's impossible to find two or three cards with the same number. Hence, Limak does nothing and the sum is 7 + 9 + 1 + 3 + 8 = 28.In the third sample, all cards have the same number. It's optimal to discard any three cards. The sum of two remaining numbers is 10 + 10 = 20.

cards=list(map(int,input().split()))
c=0
for i in cards:
	if cards.count(i)>=2 and i*cards.count(i)>c:
		if cards.count(i)>3:
			c=i*3
		else: c=i*cards.count(i)

print (sum(cards)-c)

from collections import Counter

T = map(int, raw_input().split())
t = Counter(T)
total = sum(T)
mn = total

for v in t.keys():

    if t[v] >= 2:
        mn = min(mn, total - v * min(3, t[v]))

print mn

l = list(map(int,input().split()))
try:
    r = max(x * min(3,l.count(x)) for x in l if l.count(x) >= 2)
    print (sum(l) - r)
except:
    print (sum(l))

s = [int(i) for i in input().split()]
s.sort()
g = 10000000
for i in range(2, -1, -1):
    if (s[i] == s[i + 1] == s[i + 2]):
        g = sum(s) - s[i] * 3
        break
for i in range(3, -1, -1):
    if (s[i] == s[i + 1]):
        g = min(sum(s) - s[i] * 2, g)
        break
g = min(sum(s), g)
print(g)

x = list(map(int, input().split()))
x_init = x.copy()
x.sort()
i = 0
while i != len(x):
    if x.count(x[i]) == 1 or x.count(x[i]) > 3:
        del x[i]
        i = -1
    i += 1
if len(x) != 0:
    cur_max, cur_min = x[0], x[0]
for j in range(1, len(x)):
    if x[j] == x[j - 1]:
        cur_min += x[j]
        if j == len(x) - 1 and cur_min > cur_max:
            cur_max = cur_min
    else:
        if cur_min > cur_max:
            cur_max = cur_min
        cur_min = x[j]
if len(x) != 0:
    print(sum(x_init) - cur_max)
else:
    print(sum(x_init))

numbers = list(map(int, input().split()))

sum = 0

count = []
for i in range(0, 101):
    count.append(0)

for number in numbers:
    count[number] += 1
    sum += number

current_sum = sum
for number in numbers:
    if count[number] >= 2:
        if count[number] >= 3:
            multiply = 3
        else:
            multiply = 2
        if (sum - number * multiply) < current_sum:
            current_sum = sum - number * multiply

print(current_sum)

n = list(map(int, input().split()))
summa = 0
maxel = 0
one = []
two = []
three = []
for k in range(len(n)):

    if n.count(n[k]) == 2:
        two.append(n[k])
    elif n.count(n[k]) >= 3:
        three.append(n[k])
    one.append(n.count(n[k]))
for i in range(len(n)):
    if len(three) == 5:
        print(three[0] * 2)
        break
    else:
        if len(three) >= 3:

            if len(two) == 2:

                if two[0] * 2 > three[0] * 3:
                    print(three[0] * 3)

                    break
                else:
                    print(two[0] * 2)
                    break
            # elif three[0] * 3 > sum(n) - three[0] * 3:
            #     print(sum(n) - three[0] * 3)
            #     break
            else:
                print(sum(n) - three[0] * 3)
                break

        elif sum(one) == 5:

            print(sum(n))
            break
        else:

            print(sum(n) - (max(two) * 2))
            break

a=[int(i) for i in input().split()]
s=sum(a)
mi=s
for i in a:
    n=a.count(i)
    if n>2:
        mi=min(mi,s-3*i)
    elif n==2:
        mi=min(mi,s-2*i)
print(mi)

a=list(map(int,input().split()));b=0
for i in a:
    if a.count(i)>=2:b=[max(b,2*i),max(b,3*i)][a.count(i)>2]
print(sum(a)-b)

t=list(map(int,input().split()))
sumt=sum(t)
arr=[]
#darr=[]
for i in range(0,5):
	for j in range(i,5):
		if i!=j:
			#print(i,j)
			if t[i]==t[j]:
				arr.append(sumt-t[i]-t[j])
				#darr.append(t[i])
for i in range(0,5):
	for j in range(i,5):
		for k in range(j,5):
			if i!=j!=k:
				#print(i,j,k)
				if t[i]==t[j]==t[k]:
					arr.append(sumt-t[i]-t[j]-t[k])
					#darr.append(t[i])
#print(darr)
#print(arr)
if arr==[]:
	print(sumt)
else:
	print(min(arr))

cards  = sorted(map(int, raw_input().split()))
su = sum(cards)
takeaway=0
counts= [cards.count(cards[i]) for i in range(5)]
for i in range(0,4):
    if (counts[i]>=2):
        if (counts[i+1]>=2):
            b=cards[i]+cards[i+1]
            takeaway=max([takeaway,b])
for i in range(0,3):
    if (counts[i]>=3):
         if (counts[i+1]>=3):
              if (counts[i+2]>=3):
                  b=cards[i]+cards[i+1]+cards[i+2]
                  takeaway=max([takeaway,b])
su=su-takeaway
print(su)

t = map(int, raw_input().split())
m = 0
for i in range(5):
# delete doubles
	for j in range(i+1, 5):
		if t[i] == t[j]: m = max(m, 2 * t[i])

for i in range(5):
# delete doubles
	for j in range(i+1, 5):
		for k in range(j+1, 5):
			if t[i] == t[j] and t[j] == t[k]: m = max(m, 3 * t[i])
print sum(t) - m,

# -*- coding: utf-8 -*-
"""
Created on Wed Jun 08 20:36:54 2016

@author: Dell_
"""

import sys
if False:
    input = open('bear.txt', 'r')
else:
    input = sys.stdin

nums = input.readline().split()
multi = []
new = []
tester = False
Sum = 0
final = 0
sumHigh = 0
sumLow = 0
finalSum = 0

for i in nums:
    if nums.count(i) > 1:
            multi.append(i)
            tester = True
for r in nums:
    r = int(r)
    Sum = Sum + r

if tester:
    for i in multi:
        a = int(i)
        new.append(a)
    new.sort()
    high = new[-1]

    if len(new) == 2 or len(new) == 3:
        sumHigh = high * len(new)
        final = sumHigh

    elif len(new) == 4:
        if new.count(high) == 4:
            sumHigh = high * 3

        else:
            sumHigh = high * 2
            low = new[1]
            sumLow = low * 2

        if sumHigh > sumLow:
            final = sumHigh
        else:
            final = sumLow

    elif len(new) == 5:
        if new.count(high) == 5:
            sumHigh = high * 3

        else:
            sumHigh = high * new.count(high)
            low = new[1]
            sumLow = low * new.count(low)

        if sumHigh > sumLow:
            final = sumHigh
        else:
            final = sumLow

    finalSum = Sum - final
    print finalSum

else:
    print Sum

t=map(int,raw_input().split());
t.sort();L=[];
for i in xrange(3):
    if (t[i]==t[i+1] and t[i+2]==t[i]):
        L.append(3*t[i]);
for i in xrange(4):
    if (t[i]==t[i+1]):
        L.append(2*t[i]);
if (len(L)>0):
    print sum(t)-max(L);
else:
    print sum(t);

# Amirhossein Alimirzaei
# University Of Bojnourd
# Telegram : @HajLorenzo
# Instagram : amirhossein_alimirzaei
# CodeForcesian ;)

_=list(map(int,input().split()))
__=list(set(_))
_____=[]
if _.count(__[0])==len(_):
    print(sum(_)-__[0]*3)
else:
    for ___ in range(len(__)):
        if _.count(__[___])>1:
            tmp=_.copy()
            ______=0
            for ____ in range(_.count(__[___])):
                ______ += 1
                if ______ == 4:
                    break
                tmp.remove(__[___])
            _____.append(sum(tmp))
    print(min(_____) if len(_____)>0 else sum(_))

arr = list(map(int, input().split()))

counts = dict()
mx = -1

for i in arr:
    if i in counts:
        counts[i] += 1
    else:
        counts[i] = 1

for k, v in counts.items():
    if v >= 2:
        mx = max(mx, k * min(v, 3))

if mx != -1:
    print(sum(arr) - mx)
else:
    print(sum(arr))

#!/usr/bin/env python

from __future__ import print_function
import sys

DEBUG = '-d' in sys.argv

def debug(*args, **kwargs):
    if DEBUG:
        print(*args, file=sys.stderr, **kwargs)

    return None

ts = map(int, raw_input().split())

from collections import defaultdict
counts = defaultdict(int)

for t in ts:
    counts[t] += 1

s = sum(ts)

counts = [(t, ctr) for (t, ctr) in counts.items() if ctr > 1]

if counts != []:
    t, ctr = max(counts, key=lambda (t, ctr): min(ctr, 3) * t)
    s -= min(ctr, 3) * t

print(s)

l = list(map(int, input().split()))
orig = sum(l)
ans = sum(l)
for i in l:
    if l.count(i) == 2:
        ans = min(ans, orig-i*2)
    elif l.count(i) >= 3:
        ans = min(ans, orig-i*3)
print(ans)

nums = list(map(int,input().split()))
totalSum = sum(nums)
ans = totalSum
if len(nums)!=len(set(nums)):
    for x in nums:
        if nums.count(x)>1 and nums.count(x)<4 and ans > (totalSum - x*nums.count(x)):
            ans = (totalSum - x*nums.count(x))
        if nums.count(x)>=4 and ans > (totalSum - x*3):
            ans = totalSum - x*3
print(ans)

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict
from math import factorial as f
from fractions import gcd as g

l = [int (i) for i in raw_input ().split ()]
ret = sum (l)
d = defaultdict (int)
for i in l: d [i] += 1
for i in d:
    if d [i] == 2:
        ret = min (ret, sum (l) - i * 2)
    if d [i] > 2:
        ret = min (ret, sum (l) - i * 3)
print ret

t = map(int, raw_input().split())
s = sum(t)
m2, m3 = 0, 0
for n in t:
    if t.count(n) >= 3:
        m3 = n * 3
    if t.count(n) == 2:
        m2 = max(m2, n * 2)
print(s - max(m2, m3))

t = sorted(list(map(int, input().split())))
b = []
for i in range(5):
	if t.count(t[i])>1:
		if t.count(t[i])>3:
			b.append(t[i]*3)
		else:
			b.append(t[i]*t.count(t[i]))
if len(b)==0:
	print(sum(t))
else:
	print(sum(t)-max(b))

l=[int(i) for i in raw_input().split()]
h=[0]*101
s=sum(l)
for i in l:
    h[i]+=1
m=s
for i in xrange(1,101):
    if(h[i]==2):
        m=min([m,s-2*i])
    if h[i]>=3:
        m=min([m,s-3*i])
print m

l=list(map(int, input().split()))
maxx=0
for i in set(l):
  if l.count(i)>=2:
    maxx=max(min(3,l.count(i))*i,maxx)
print(sum(l)-maxx)

a = list(map(int,input().split()))
r = list(set(a))
d = {}
for i in r:
	if a.count(i)>=2:
		d[i] = a.count(i)
max1 = 0
for i in d:
	if d[i]>2:
		if i*3 > max1:
			max1 = i*3
	else:
		if i*2 > max1:
			max1 = i*2
print(sum(a)-max1)

def f(l,i):
	k = list(range(4))
	jj = 0
	for j in range(5):
		if j!=i:
			k[jj] = l[j]
			jj += 1
	return k
l = list(map(int,raw_input().split(' ' )))
m = sum(l)
for i in range(5):
	k = f(l,i)
	if l[i] in k:
		t=2
		while t and l[i] in k:
			t -=1
			k.pop(k.index(l[i]))
		if m>sum(k):
			m = sum(k)
print(m)

import collections

def minCardSum(arr):
    count = collections.Counter(arr)
    current = 0
    for num in arr:
        if count[num] > 1 and num * min(count[num], 3) > current:
            current = min(count[num], 3) * num
    return sum(arr) - current

print(minCardSum(list(map(int, input().split()))))

arr = map(int, raw_input().split())

arr = sorted(arr)
l=len(arr)
sum2 = 0
sum3 = 0
s=sum(arr)

cnt = 1
for x in range(l - 1):
    if (arr[x] == arr[x+1]):
        cnt += 1
        if (cnt == 2 and cnt*arr[x] > sum2):
            sum2 = 2*arr[x]

        elif (cnt == 3 and cnt*arr[x] > sum3):
            sum3 = 3*arr[x]
    else:
        cnt = 1

print s - max(sum2, sum3)

import sys
from collections import Counter

if __name__ == "__main__":
    cards = [int(i) for i in sys.stdin.readline().strip().split()]
    c = sorted(((key, value) for key, value in Counter(cards).iteritems() if value > 1), key=lambda x: x[0]*x[1])
    if c:
        value = c[-1]
        print sum(cards) - min(value[1], 3) * value[0]
    else:
        print sum(cards)

t1, t2, t3, t4, t5 = raw_input().split()
t1 = (int)(t1); t2 = (int)(t2); t3 = (int)(t3); t4 = (int)(t4); t5 = (int)(t5)
arr = [t1, t2, t3, t4, t5]
sum = t1 + t2 + t3 + t4 + t5
max = 0;
i = 0
while i < 5:
	if arr.count(arr[i]) == 2:
		if (max < arr.count(arr[i])*arr[i]):
			max = arr.count(arr[i])*arr[i]
	elif arr.count(arr[i]) >= 3:
		if (max < 3*arr[i]):
			max = 3*arr[i]
	i += 1
print sum - max

t=map(int,raw_input().split())
ans=0
for i in t:
    k=t.count(i)
    if k>=2:
        ans=max(ans,min(k,3)*i)
print sum(t)-ans

#!/usr/bin/env python
# -*- coding: utf-8 -*-

t = [int(i) for i in raw_input().split()]
a = {}
s = 0
for i in t:
    a[i] = a.get(i, 0) + 1
    s += i

m = 0
for i in a.keys():
    if a[i] == 2 or a[i] == 3:
        m = max(a[i] * i, m)
    elif a[i] >= 3:
        m = max(3 * i, m)

print(s - m)

l = list(map(int,input().split()))
z = []
if len(set(l)) == len(l):
    print(sum(l))

else:
    for i in set(l):
        if l.count(i) > 1:
            z.append(i*min(l.count(i),3))
    print(sum(l)-max(z))

r=lambda:map(int,raw_input().split())
t=r()

s=0

for e in set(t):
    for i in [2,3]:
        if t.count(e) >= i:
            s = max(s, e*i)
print sum(t)-s

a, b = list(map(int, input().split())), []
for i in set(a):
    if a.count(i) >= 3:
        b.append(i*3)
    if a.count(i) == 2:
        b.append(i*2)
print(sum(a) - max(b) if len(b) != 0 else sum(a))
# happy new year
#CodeForcesian

l = list(map(int, input().split()))
mn = sum(l)
for i in range(1, 101):
	if l.count(i) >= 2:
		mn = min(mn, sum(l) - i * 2)
	if l.count(i) >= 3:
		mn = min(mn, sum(l) - i * 3)
print(mn)

a = list(map(int, input().split()))
b2 = [0]*101
b3 = [0]*101

for x in a:
    b2[x] += 1
    b3[x] += 1

for i in range(100, 0, -1):
    if b3[i] >= 3:
        b3[i] -= 3
        break

for i in range(100, 0, -1):
    if b2[i] >= 2:
        b2[i] -= 2
        break

print(min(
    sum(i*x for i, x in enumerate(b2)),
    sum(i*x for i, x in enumerate(b3))))

t = sorted(list(map(int, input().split(" "))))
s = sum(t)
result = s
for i in range(4):
    if t[i] == t[i+1]:
        result = min(result, s-sum(t[i:i+2]))
for i in range(3):
    if t[i] == t[i+2]:
        result = min(result, s-sum(t[i:i+3]))
print(result)

t = [int(x) for x in input().split()]

minsum = sum(t)

for i in t:
    icount = t.count(i)
    if icount >= 3:
        minsum = min(minsum, sum(t) - 3 * i)
    if icount >= 2:
        minsum = min(minsum, sum(t) - 2 * i)

print(minsum)

nums = map(int,raw_input().split())
ans=sum(nums)

nums.sort()
minus = 0
for i in xrange(4) :
	if nums[i]==nums[i+1] :
		if i+2<=4 and nums[i]==nums[i+2] :
			if 3*nums[i] > minus :
				minus = 3*nums[i]
		else :
			if 2*nums[i] > minus :
				minus = 2*nums[i]
print ans-minus

t = list(map(int, input().split()))
triples = [s for s in t if t.count(s) >= 3]
doubles = [s for s in t if t.count(s) == 2]
triples.sort()
doubles.sort()
m = 0
if triples:
    m = 3*triples[-1]
if doubles:
    m = max(m, 2*doubles[-1])
print(sum(t)-m)

list=[int(i) for i in input().split()]
som=sum(list)
list.sort(reverse=True)
res=[som]
for i in range(5):
    k=list.count(list[i])
    if(k>=2 and k<=3):
        res.append(som-list[i]*k)
    elif(k>=4):
        res.append(som-list[i]*3)
print(min(res))

a=[]
a=list(map(int,input().split()))
a.sort()
i=4
s=sum(a)
count=0
b=[]
b.append(0)
while(i>=0):
	k=a.count(a[i])
	if k>=2:
		if k==2:
			b.append(a[i]*k)
		else:
			b.append(a[i]*3)
	i-=1
sminus=max(b)
s=s-sminus
print(s)

# coding: utf-8
num = raw_input().split()
num = map(int, num)
num.sort()
s = sum(num)
ans = s
for i in range(4):
    if num[i] == num[i+1]:
        ans = s - num[i]*2

for i in range(3):
    if num[i] == num[i+1] and num[i+1] == num[i+2]:
        ans = min(ans, s-num[i]*3)

print ans

t = list(map(int, input().split()))
tset = list(set(t))
t.sort()
if len(tset) == 1:
    print(tset[0] * 2)
elif len(tset) == 2:
    if t.count(tset[0]) == 1 or t.count(tset[0]) == 4:
        print(tset[0] + tset[1])
    else:
        print(min(t.count(tset[0]) * tset[0], t.count(tset[1]) * tset[1]))
elif len(tset) == 3:
    for i in range(3):
        if t.count(tset[i]) == 3:
            print(sum(t) - 3 * tset[i])
            exit()
    else:
        t.sort()
        if t.count(max(t)) == 1:
            print(sum(t) - 2 * t[3])
        else:
            print(sum(t) - 2 * t[4])
        exit()
elif len(tset) == 4:
    for i in range(4):
        if t.count(tset[i]) == 2:
            print(sum(t) - 2 * tset[i])
            exit()
else:
    print(sum(t))

a=list(map(int,input().split()))
su=sum(a);b=[]
for i in set(a):
    b.append(i*(a.count(i)//3)*3)
    b.append(i*(min(2,(a.count(i)//2)*2)))
print(su-max(b))

l = map(int, raw_input().strip().split(" "))
l.sort()
dic = {}

for i in l:
	if i in dic:
		dic[i] = dic[i] + 1
	else:
		dic[i] = 1
m = []
for i in dic:
	if dic[i]>=2:
		m.append(i)

for i in dic:
	if dic[i]>3:
		dic[i] = 3
if len(m)==0:
	print sum(l)
elif len(m)==1:
	print sum(l)-m[0]*min(3,dic[m[0]])
elif len(m)==2:
	y = max(m[0]*dic[m[0]], m[1]*dic[m[1]])
	print sum(l)-y

a=map(int,raw_input().split())
a.sort()
a.reverse()
x=sum(a)
res=0
for i in a:
	if a.count(i)>=3:
		res=max(res,3*i)
	elif a.count(i)>=2:
		res=max(res,2*i)
print x-res

li = [int(i) for i in input().split()]
d = dict()
for i in li:
    if i not in d:
        d[i] = 1
    else :
        d[i] += 1
if len(d) == 5:
    print(sum(list(d.keys())))
elif len(d) == 4:
    sm = 0
    for i in d:
        if d[i] != 2:
            sm += i
    print(sm)
elif len(d) == 3:
    sm1, sm2, sm3 = 0, 0, 0
    if 3 in list(d.values()):
        for i in d:
            if d[i] != 3:
                sm1 += i
        print(sm1)
    else :
        key = 0
        for i in d:
            if d[i] == 2 and key == 0:
                sm2 += i * 2
                key = i
            elif d[i] != 2 :
                sm2 += i
        for i in d:
            if d[i] == 2 and key != i :
                sm3 += i * 2
            elif d[i] != 2:
                sm3 += i
        print(min(sm2, sm3))
elif len(d) == 2:
    sm1, sm2, sm3 = 0, 0, 0
    for i in d:
        if d[i] == 3:
            sm1 += i * 3
        elif d[i] == 2:
            sm2 += i * 2
    for i in d:
        if d[i] == 4:
            sm3 += i
        elif d[i] == 1:
            sm3 += i
    if sm1 != 0 and sm2 != 0:
        print(min(sm1, sm2))
    elif sm3 != 0 :
        print(sm3)
elif len(d) == 1:
    for i in d:
        print(2 * i)

a=list(map(int,raw_input().split()))
d={}
for i in a:
    d[i]=0
for i in a:
    d[i]+=1
ans=sum(a)
for i in d:
    if d[i]>=3:
        ans=min(ans,sum(a)-3*i)
    elif d[i]>=2:
        ans=min(ans,sum(a)-2*i)
print ans

cards=list(map(int,input().split()))
c=0
for i in cards:
	if cards.count(i)>=2 and i*cards.count(i)>c:
		if cards.count(i)>3:
			c=i*3
		else: c=i*cards.count(i)

print (sum(cards)-c)

import sys
import math
import bisect
import itertools
import random

def main():
    A = list(map(int, input().split()))
    d = dict()
    for a in A:
        if a not in d:
            d[a] = 0
        d[a] += 1
    min_val = sum(A)
    for a in d:
        if d[a] >= 2:
            val = sum(A) - a * 2
            min_val = min(min_val, val)
        if d[a] >= 3:
            val = sum(A) - a * 3
            min_val = min(min_val, val)
    print(min_val)

if __name__ == "__main__":
    main()

def f(l):
    i = 0
    while i!=len(l):
        if l.count(l[i])>1:
            del l[i]
        else:
            i+=1
    return l
l = raw_input().split(" ")
for i in range(5):
    l[i] = int(l[i])
l1 = f(l[:])
l2 = []
l3 = []
for i in range(len(l1)):
    if l.count(l1[i])>1:
        if l.count(l1[i])<4:
            l2.append(l1[i]*l.count(l1[i]))
        else:
                    l2.append(l1[i]*3)
                    l2.append(l1[i]*(l.count(l1[i])-3))
    else:
        l3.append(l1[i])
l2 = sorted(l2)
print sum(l2[:-1])+sum(l3)

c = map(int, raw_input().split())
t = 0
for x in c:
  d = c.count(x)
  if d > 1:
    t = max(t, x * min(d, 3))
print sum(c) - t

from collections import Counter

ls = list(map(int, input().split()))
ls.sort()
ls.reverse()
d = dict(Counter(ls))
Max = 0
for k, v in d.items():
    if v>=3: Max = max(Max, 3*k)
    if v==2: Max = max(Max, 2*k)
print(sum(ls)-Max)

ip = raw_input()
ipl = [int(i) for i in ip.split()]
count = 0
var = []
large = 0
for y in xrange(0,101):
	var.append(0)

for x in xrange(0,5):
	count = count + ipl[x]
	var[ipl[x]] = var[ipl[x]] + 1

for z in xrange(1,101):
	if 2 <= var[z] <= 3 :
		if large < var[z]*z :
			large = var[z]*z
	elif var[z] > 3 :
		large = 3*z

print count - large

y=sorted(list(map(int,input().split())))
p=[]
for i in range(1,len(y)):
        x=y.count(y[-i])
        if x>=2:
                if x<=3:p.append(sum(y)-y[-i]*x)
                else:p.append(sum(y)-y[-i]*3)
print(sum(y) if len(p)==0 else min(p))

c = map(int, raw_input().split())
s = sum(c)
e = 0
q = 0
for x in c:
	if c.count(x) >=3:
		e = x*3
	elif c.count(x) == 2:
		q = max(q, x*2)
print s-max(e,q)

l = list(map(int, input().split()))
orig = sum(l)
ans = sum(l)
for i in l:
    if l.count(i) == 2:
        ans = min(ans, orig-i*2)
    elif l.count(i) >= 3:
        ans = min(ans, orig-i*3)
print(ans)

l = list(map(int,input().split()))
s = sum(l)
a = list(set(l))
c = []
for i in a:
    x = l.count(i)
    if(x>=3):
        c.append(3*i)
    elif(x>=2):
        c.append(2*i)
    else:
        c.append(0)

print(s-max(c))

read = lambda: map(int, input().split())
t = sorted(read())
Sum = ans = sum(t)
a = set(t)
for i in a:
    if t.count(i) == 1: continue
    cur = Sum - min(3, t.count(i)) * i
    ans = min(ans, cur)
print(ans)

x=[]
x=map(int,raw_input().split())
dict={}
y=[]
sum=0
for i in x:
    if i in dict.keys():
        dict[i]+=1
    else:
        dict[i]=1
    sum+=i

if dict.keys==len(x):
    print sum
else:
    m=sum
    for key,value in dict.iteritems():
        if value>1:
            m=min(m,sum-(key*min(max(2,value),3)))
    print m

a=list(map(int, input().split()))
b={};sum=0

for i in a:
	if i not in b:
		b[i]=1
	else:
		b[i]+=1
p=[]
for i, j in b.items():
	if j==1:
		sum+=i
	elif j>3:
		sum+=i*(j-3)
	else:
		p+=[i*j]
if len(p)>1:
	sum+=min(p)
print(sum)

lst=[int(i) for i in input().split()]
sum1=sum(lst)
min1=sum1
for i in lst:
    nd=0
    for j in lst:
        if i==j:
            nd+=1
    if nd>3:
        nd=3
    c=sum1-(i*nd)
    #print(i,nd)
    if c<min1 and nd>1:
        min1=c
print(min1)

from collections import Counter
A = map(int, raw_input().split())
C = Counter(A)
Th = filter(lambda x: C[x]>=3 ,C)
Tw = filter(lambda x: C[x]==2 ,C)
if Th and Tw:
	print sum(A) - max(Th[0]*3, Tw[0]*2)
elif Th:
	print sum(A) - Th[0]*3
elif Tw:
	print sum(A) - max(Tw)*2
else:
	print sum(A)

from collections import Counter

t = Counter(map(int, raw_input().split()))

max_sum = 0
for value, count in t.items():
    if count > 1:
        new_sum = value * min(count, 3)
        if not max_sum:
            max_sum = new_sum

        elif max_sum < new_sum:
            max_sum = new_sum

print sum(k * v for k, v in t.items()) - max_sum

t = map(int, raw_input().split())
same = False

for i in range(1,5):
	for j in range(i):
		if t[i] == t[j]:
			same = True
			break
	if same:
		break
	else:
		continue

if same:
	t.sort()
	numbers = [t[0]]
	times = [1]
	j = 0
	for i in range(1,5):
		if t[i] == t[i-1]:
			times[j] += 1
		else:
			numbers.append(t[i])
			j += 1
			times.append(1)

	sums = []
	for i in range(len(times)):
		if times[i] == 2:
			sums.append(sum(t) - numbers[i] * times[i])
		elif times[i] >= 3:
			sums.append(sum(t) - numbers[i] * 3)
		else:
			continue
	print min(sums)

else:
	print sum(t)

a = map(int, raw_input().split())
d = [0 for _ in xrange(101)]
ss = 0
for i in a:
    ss += i
    d[i] += 1

mn = ss
for i in xrange(100, 0, -1):
    if d[i] == 2:
        mn = min( mn, ss - i * d[i])
    elif d[i] >= 3:
        mn = min( mn, ss - i * 3)

print mn

l = list(map(int,input().split()))
try:
    r = max(x * min(3,l.count(x)) for x in l if l.count(x) >= 2)
    print (sum(l) - r)
except:
    print (sum(l))

#coding: utf-8
arr = raw_input()
num = arr.split()
sum = 0
ar = []
for x in num:
    ar.append(int(x))
    sum += int(x)
maxx = 0
dic = {}
for x in ar:
    dic[x] = 0
for x in ar:
    dic[x]+=1
maxx = 0
for x in ar:
    if dic[x] == 2:
        maxx = max(x*2,maxx)
    elif dic[x] >=3:
        maxx = max(x*3,maxx)
print sum - maxx

nums = map(int,raw_input().split())
ans=sum(nums)

nums.sort()
minus = 0
for i in xrange(4) :
	if nums[i]==nums[i+1] :
		if i+2<=4 and nums[i]==nums[i+2] :
			if 3*nums[i] > minus :
				minus = 3*nums[i]
		else :
			if 2*nums[i] > minus :
				minus = 2*nums[i]
print ans-minus

l = list(map(int,input().split()))+[0]
ans = sum(l)
for k in l:
    if l.count(k) >= 2:
        ans = min(sum(l) - min(l.count(k),3)*k,ans)
print(ans)

a = [int(i) for i in input().split()]

c = [0] * 101
ss = 0

for i in a:
    c[i] += 1
    ss += i

m = 0
for i in range(101):
    if (c[i] > 1) and (i * min(c[i], 3) > m):
        m = i * min(c[i], 3)

print(ss - m)

def solution(l1):
    l1.sort()
    i=0
    ans=[0]
    while i<len(l1):
        targ=l1[i]
        j=0
        count=0
        while j<len(l1):
            if l1[j]==targ:
                count+=1
            j+=1
        if count>=3:
            ans.append(3*targ)
        elif count>=2:
            ans.append(2*targ)
        i+=1
    ans.sort()
    ans.reverse()
    return sum(l1)-ans[0]

def answer():
    l1 = [int(x) for x in input().split()]
    print(solution(l1))
answer()

a = map(int, raw_input().split())
a.append(0)
a.append(0)
print sum(a) - max(min(a.count(e),3)*e for e in a if a.count(e)>1)

a = list(map(int, input().split()))
S = sum(a)
res = S

for x in a:
	n = a.count(x)
	if n >= 2:
		res = min(res, S - min(3, n) * x)

print(res)

from collections import defaultdict,deque,Counter,OrderedDict
import sys
sys.setrecursionlimit(20000)
def main():
    l = list(map(int,input().split()))
    ans,tos = sum(l),0
    mp = defaultdict(int)
    for i in l: mp[i] += 1
    for k in mp:
        if mp[k] >= 3:
           tos = max(tos,k*3)
        if mp[k] >= 2:
            tos = max(tos,k*2)
    print(ans - tos)

if __name__ == "__main__":
    main()

a=list(map(int,input().split()));b=0
for i in a:b=[b,[max(b,2*i),max(b,3*i)][a.count(i)>2]][a.count(i)>=2]
print(sum(a)-b)

#!/usr/bin/env python

def main():
    cards = [int(x) for x in raw_input().split()]
    dict_cnt = {}
    for card in cards:
        if card in dict_cnt:
            dict_cnt[card] += 1
        else:
            dict_cnt[card] = 1
    discard = [3 * x if dict_cnt[x] >= 3 else 2 * x
               for x in dict_cnt if dict_cnt[x] >= 2]
    print sum(cards) - (max(discard) if discard else 0)

if __name__ == '__main__':
    main()

a = [x for x in range(5)]
a[0],a[1],a[2],a[3],a[4] = map(int,input().split())
a.sort()
#print(a)
ans = 0
for i in range(5):
	ans += a[i]
Max = 0
tsum = a[0]
count = 1
for i in range(4):
	if a[i]==a[i+1] and count < 3:
		tsum+=a[i+1]
		count = count + 1
		if tsum > Max :
			Max = tsum
	else:
		tsum = a[i+1]
		count =1
ans -= Max
print(ans)

vlist=[int(x) for x in raw_input().split()]
vlist.sort()
last=0
num=1
mi=0
for x in vlist:
    if x==last and num<=2:
        num += 1
        mi=max(mi,x*num)
    else:
        num=1
    last=x
print sum(vlist)-mi

l = list(map(int,input().split()))
s = sum(l)
a = list(set(l))
a = a[::-1]
c = []
for i in a:
    c.append(l.count(i))
z = c.index(max(c))
if(c[z]>=3):
    s-=3*a[z]
elif(c[z]>=2):
    s-=2*a[z]

print(s)

from collections import Counter

list = map(int, raw_input().split())
arr1 = []
arr2 = []
k = Counter(list)
for i in k:
    arr1.append(i)
    arr2.append(k[i])
k2= 100000
k1=0
k3=0
k4=0
k5=0

for i in xrange(len(arr2)):
    if(arr2[i]==2):
        if(arr1[i]<max):
            k2 = arr1[i]
            max = arr1[i]
if(k2 == 100000):k2=0
k2=k2*2
for i in xrange(len(arr2)):
    if(arr2[i]==1):
        k1 = k1+arr1[i]

for i in xrange(len(arr2)):
    if(arr2[i]==3):
        k3=arr1[i]*3
        if(k3>k2):
            k3=k2
            k2=0

for i in xrange(len(arr2)):
    if(arr2[i]==4):
        k4 = arr1[i]

for i in xrange(len(arr2)):
    if(arr2[i]==5):
        k5=arr1[i]*2

print k1+k2+k3+k4+k5

a = list(map(int, input().split()))
a = sorted(a)
t = 0
q = 0
p = 0
for j in range(5):
    p += a[j]

for i in range(4,0,-1):
    if a[i] == a[i-2]:
        q += 3*a[i]
        break
for k in range(4,0,1):
    if a[k] == a[k-1]:
        t += 2*a[k]
        break

print(p-max(t,q))

#!/usr/bin/python

a = raw_input ()
a = a . split ()
b = []
c = []
e = []
f = []
g = []
o = []

if len (a) == 5 :

    for x in a :

        x = int (x)
        if 1 <= x <= 100 :
            e.append (x)
            o.append (x)
        else :
            quit ()

    for x in o :

        if o.count (x) >= 3 :
            #print '33333333'

            if x not in b :
                e = o
                while len (b) != 3 :
                    #print 'e',e
                    e.pop (e.index(x))
                    #print 'e',e
                    b.append (x)
                    #print 'b',b
                f . append ( sum (e) )
                e = o

        elif o.count (x) == 2 :
            #print '22222222'
            if x not in c :
                while len (c) != 2 :
                    #print 'e',e
                    e.pop (e.index(x))
                    #print 'e',e
                    c.append (x)
                    #print 'c',c
                if len (g) == 2 :
                    e = o
                    break
                g . append ( sum (e) )
                #print 'g',g
                e = o

    if len (f) != 0 :
        h = min (f)
    else :
        h = 0

    if len (g) != 0 :
        j = min (g)
    else :
        j = 0

    if h != 0 and j != 0 :
        print min ( h , j )
    elif h == 0 and j != 0 :
        print j
    elif h != 0 and j == 0 :
        print h
    else :
        print sum (o)

arr=map(int,raw_input().strip().split(" "))
arr.sort()
su=sum(arr)
if(arr[4]==arr[3]):
    if(arr[3]==arr[2]):
        su=su-arr[4]*3
    else:
        if(arr[2]==arr[1]):
            if(arr[1]==arr[0]):
                su=su-max(arr[4]*2,arr[2]*3)
            else:
                su=su-arr[4]*2
elif(arr[3]==arr[2]):
    if(arr[2]==arr[1]):
        su=su-arr[3]*3
    else:
        su=su-arr[3]*2
elif(arr[2]==arr[1]):
    if(arr[1]==arr[0]):
        su=su-arr[2]*3
    else:
        su=su-arr[2]*2
elif(arr[1]==arr[0]):
    su=su-arr[1]*2
print su

lst=[int(i) for i in input().split()]
sum1=sum(lst)
min1=sum1
for i in lst:
    nd=0
    for j in lst:
        if i==j:
            nd+=1
    if nd>=3:
        nd=3
    c=sum1-(i*nd)
    if c<min1:
        min1=c

print(min1)

li=list(map(int,input().split()))

sm = sum(li)

mn=sm

for i in li:

    cnt=li.count(i)

    if cnt>=2:

         mn = min(sum(li)-cnt*i, mn)
print(mn)

a=list(map(int,input().split()))
a.sort(reverse=True)
p_ans=0
for i in range(len(a)-1):
	if a[i]==a[i+1]:
		if i!=0:
			if a[i]==a[i-1]:
				c=3*a[i]
				if p_ans<c:
					p_ans=c
				else:
					continue
			else:
				c=2*a[i]
				if p_ans<=c:
					p_ans=c
				else:
					continue
	else:
		continue
print(sum(a)-p_ans)

n=list(map(int,input().split()))
x=list(set(n))
x.sort()
c=[n.count(i) for i in x]
c.sort
l=len(c)
if(len(x)==5):
	print(sum(n))
else:
	ans=0
	for i in range(l):
		if(c[i]==2):
			ans=2*(x[i])

	if( 3 in c or 4 in c or 5 in c):
		if(3*(x[-1])>ans):
			ans=3*(x[-1])

	print(sum(n)-ans)

ns = map(int, raw_input().split())

d = {}

for num in ns:
    d[num] = d.get(num, 0) + 1

s = sum(ns)
ans = 0xFFFFFFFF

for key, value in d.items():
    if value >= 2:
        ans = min(ans, s - 2 * key)
    if value >= 3:
        ans = min(ans, s - 3 * key)

print ans

t = map(int, raw_input().split())
ans = 0
for i in t:
	k = t.count(i)
	if(k>=2):
		ans = max(ans,k*i)
print sum(t)-ans

a = list(map(int, input().split()))
b = [0]*101

for x in a:
    b[x] += 1

for i in range(100, 0, -1):
    if b[i] >= 3:
        b[i] -= 3
        break
    if b[i] >= 2:
        b[i] -= 2
        break

print(sum(i*x for i, x in enumerate(b)))

a=list(map(int,input().split()))
a.sort(reverse=True)
d={}
for i in range(len(a)):
    if a[i] not in d:
        d[a[i]]=1
    else:
        d[a[i]]+=1
f=0
for i in range(len(a)):
    if d[a[i]]>=3:
        print(sum(a)-a[i]*3)
        f=1
        break
    elif d[a[i]]>=2:
        print(sum(a)-a[i]*2)
        f=1
        break
if f==0:
    print(sum(a))

li=list(map(int,input().split()))
ki=[]
for i in range(len(li)):
 k=li.count(li[i])
 if k>1:
   if k==2:
    ki.append(sum(li)-li[i]*2)
   else:
    ki.append(sum(li) - li[i] * 3)
if len(ki)>0:
 print(min(ki))
else:
  print('0')

import collections

#tt = int(raw_input())
a = map(int, raw_input().split())
dic = collections.Counter(a)
b = sum(a)
#print dic
if max(dic.values()) < 2:
	print b# 'asdf'

elif len(dic) == 1:
	print 2*dic.keys()[0]# 'qwe'

else:
	ans = 10**9
	for i in dic.keys():
		if dic[i] < 2:
			continue

		sum1 = b - i*dic[i]
		if sum1 < ans:
			ans = sum1

	print ans

n = [int(i) for i in input().split()]

if len(set(n)) == len(n):
	print(sum(n))
else:
	l2 = [n[i] for i in range(len(n)) if 3>n.count(n[i])>1]
	l3 = [n[i] for i in range(len(n)) if n.count(n[i])>2]
	#print(set(l2), set(l3))
	if set(l3) != set() and set(l2) == set():
		for i in range(3):
			n.remove(max(set(l3)))
	elif set(l3) == set() and set(l2) != set():
		for i in range(2):
			n.remove(max(set(l2)))
	elif set(l3) != set() and set(l2) != set():
			if sum(set(l2)) > sum(set(l3)):
				for i in range(2):
					n.remove(max(set(l2)))
			else:
				for i in range(3):
					n.remove(max(set(l3)))
	print(sum(n))

a=[int(i) for i in input().split()]
b=[]
s=0
for i in range(4):
    for j in range(i+1,5):
        if a[i]>a[j]:
            a[i], a[j] = a[j], a[i]
t=0
for i in range(4):
    s+=a[i]
    if a[i]==a[i+1] and t<2:
        t+=1
    else:
        if t>0:
            b.append([a[i], t+1])
            t=0
s+=a[4]
if len(b)==0:
    print(s)
else:
    m=b[0][0]*b[0][1]
    for i in b:
        if i[0]*i[1]>m:
            m= i[0]*i[1]
    print(s-m)

from collections import Counter

t = list(map(int, input().split()))
cnt = Counter(t)
print(sum(cnt) - max(2 * el if cnt[el] == 2 else 3 * el for el in cnt if cnt[el] > 1))

cards = input().split()
cards = sorted([int(x) for x in cards], reverse=True)
lowest_sum = []
tokens = 1
counter = 1
current = 0

z_counter = 0
most_repeated = []
for z in cards:
    if counter >= len(cards):
        break
    else:
        if z == cards[counter]:
            z_counter += 1
            if z_counter == 2:
                most_repeated.append(z)
                most_repeated.append(z)
                most_repeated.append(z)

        else:
            z_counter = 0
    counter += 1
counter = 1

for y in cards:
    if counter >= len(cards):
        break
    else:
        if y == cards[counter]:
            current = y
            break
        else:
            counter += 1

counter = 1

for num in cards:
    if counter >= len(cards):
        break
    else:
        if num == cards[counter] == current and tokens < 3:
            lowest_sum.append(num)
            if cards[counter] != cards[counter + 1]:
                lowest_sum.append(cards[counter])
    tokens += 1
    counter += 1
card_sum = min((sum(cards) - sum(lowest_sum)), (sum(cards) - sum(most_repeated)))
print(card_sum)

import sys

def minSum(arr):
	num_dict = {}
	for num in sorted(arr,reverse=True):
		num_dict[num] = num_dict.get(num,0)+1
	removed=False
	minsum = 0
	for k in num_dict:
		v = num_dict.get(k)
		if not removed:
			if v>1 and v<=3:
				removed = True
			elif v>3:
				minsum = minsum + k*(num_dict.get(k)-3)
				removed = True
			else:
				minsum = minsum + k*(num_dict.get(k))
		else:
			minsum = minsum + k*(num_dict.get(k))
	return minsum

def main():
	arr = list(int(x) for x in sys.stdin.readline().strip().split())

	print(minSum(arr))

main()

def arr_inp():
    return [int(x) for x in input().split()]

a = arr_inp()
ix, out = 0, sum(a)

while (ix < 5):
    a_copy = a.copy()
    c = a.count(a[ix])
    if (c >=2):
        for i in range(min(3,c)):
            a_copy.remove(a[ix])
        out=min(out,sum(a_copy))
    ix+=c
print(out)

from sys import stdin, stdout

arr=list(map(int,stdin.readline().split()))
sl=len(set(arr))
s=sum(arr)
arr.sort()
if(len(arr)==sl):
    ans=s
elif(sl==1):
    ans=arr[0]+arr[1]
else:

    map={}
    for i in arr:
        try:
            map[i]+=1
        except:
            map[i]=1
    #3 and 4
    arr = list(set(arr))
    for i in arr:
        if (map[i] < 2):
            map[i] = 0
    if(sl==3):

        ans=s-max(map[arr[0]]*arr[0],map[arr[1]]*arr[1],map[arr[2]]*arr[2])
    elif(sl==2):
        ans = s - max(map[arr[0]] * arr[0], map[arr[1]] * arr[1])
    else:
        ans = s - max(map[arr[0]] * arr[0], map[arr[1]] * arr[1], map[arr[2]] * arr[2],map[arr[3]]*arr[3])

stdout.write(str(ans)+"\n")

t = list(map(int, input().split()))
tmp = 0
for i in t:
    if t.count(i) >= 3:
        print(i * 3)
        exit()
    if t.count(i) == 2:
        if tmp < i:
            tmp = i
print(sum(t) - (tmp * 2))

# CodeForcesian
# ♥
# یا امام رضا

import sys
import math

#to read string
get_string = lambda: sys.stdin.readline().strip()
#to read list of integers
get_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )
#to read non spaced string and elements are integers to list of int
get_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))
#to read non spaced string and elements are character to list of character
get_charList_from_str = lambda: list(sys.stdin.readline().strip())
#get word sepetared list of character
get_char_list = lambda: sys.stdin.readline().strip().split()
#to read integers
get_int = lambda: int(sys.stdin.readline())
#to print faster
pt = lambda x: sys.stdout.write(str(x))

#--------------------------------WhiteHat010--------------------------------#
lst = get_int_list()
s = sum(lst)
m = max(lst, key = lambda x: ((lst.count(x)-1)*x))
print(m)
if lst.count(m) >= 3:
    print(s-3*m)
elif lst.count(m) == 2:
    print(s-2*m)
else:
    print(s)

x=[]
x=map(int,raw_input().split())
dict={}
y=[]
sum=0
for i in x:
    if i in dict.keys():
        dict[i]+=1
    else:
        dict[i]=1
    sum+=i

if dict.keys==len(x):
    print sum
else:
    m=sum
    for key,value in dict.iteritems():
        if value>1:
            m=min(sum,sum-(key*min(max(2,value),3)))
    print m

import os

import sys

debug = True

if debug and os.path.exists("input.in"):
    input = open("input.in", "r").readline
else:
    debug = False
    input = sys.stdin.readline

def inp():
    return (int(input()))

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

def insr():
    s = input()
    return s[:len(s) - 1]  # Remove line char from end

def invr():
    return (map(int, input().split()))

test_count = 1
if debug:
    test_count = inp()

for _ in range(test_count):
    a = inlt()
    ans = sum(a)
    max_discard = 0
    for x in a:
        c = a.count(x)
        if c in (2, 3):
            max_discard = max(max_discard, x * c)
    print(ans - max_discard)

t = list(map(int,input().split()))
mapp = [0]*101
for i in t:
    mapp[i] = (mapp[i] + 1) % 3
remove = 0
for i in range(100,0,-1):
    if mapp[i] > 1  and remove < mapp[i]*i:
        remove = mapp[i]*i

print(sum(t) - remove)

cards=list(map(int,input().split()))
c=0
for i in cards:
	if cards.count(i)in{2, 3} and i*cards.count(i)>c: c=i*cards.count(i)

print (sum(cards)-c)

x=list(map(int,input().split()))
b=[]
b.append(sum(x))
a=set(x)
a=list(a)
print(a)
for i in a:
    ans=0
    if(x.count(i)==3 or x.count(i)==2):
        for j in x:
            if(j!=i):
                ans+=j
    elif(x.count(i)==4):
        ans+=i
        for j in x:
            if(j!=i):
                ans+=j
    elif(x.count(i)==5):
        ans=i*2
    if(ans!=0):
        b.append(ans)
print(b)

# import sys
# sys.stdin=open("input1.in","r")
# sys.stdout=open("output2.out","w")
L=list(map(int,input().split()))
ans=sum(L)
Hash=[0]*101
for i in L:
	Hash[i]+=1
max1,maxG=0,0
for i in range(1,101):
	if 	Hash[i]==2 or Hash[i]==3:
		max1=Hash[i]*i
		if maxG<max1:
			maxG=max1
print(ans-maxG)

from collections import Counter

list = map(int, raw_input().split())
arr1 = []
arr2 = []
k = Counter(list)
for i in k:
    arr1.append(i)
    arr2.append(k[i])
k2= 100000
k1=0
k3=0
k4=0
k5=0
print arr1
print arr2
for i in xrange(len(arr2)):
    if(arr2[i]==2):
        if(arr1[i]<max):
            k2 = arr1[i]
            max = arr1[i]
if(k2 == 100000):k2=0
k2=k2*2
for i in xrange(len(arr2)):
    if(arr2[i]==1):
        k1 = k1+arr1[i]

for i in xrange(len(arr2)):
    if(arr2[i]==3):
        k3=arr1[i]*3
        if(k3>k2):
            k3=k2
            k2=0

for i in xrange(len(arr2)):
    if(arr2[i]==4):
        k4 = arr1[i]

for i in xrange(len(arr2)):
    if(arr2[i]==5):
        k5=arr1[i]*2

print k1,k2,k3,k4,k5
print k1+k2+k3+k4+k5

t = list(map(int, input().split()))

c = {0: 1}
for e in t:
    if c.get(e) is None:
        c[e] = 1
    else:
        c[e] += 1

cand = [0]
for k in c.keys():
    if c[k] > 1:
        cand.append(k)

r = max(cand)
print(sum(t) - min(3, c[r]) * r)

l = list(map(int, input().split()))
k = list(set(l))
g = 0
mx = 501

if len(k) == len(l):
    print(sum(l))
else:
    for i in range(len(l)):
        for j in range(i+1, len(l)):
            if l[i] == l[j]:
                g += 1

            if g > 3:
                g = 3

            s = sum(l) - g * l[i]
            mx = min(s, mx)

    print(mx)

l=list(map(int,input().split()))
c=list(filter(lambda x:l.count(x)>1,l))
c=list(set(c))
if c!=[]:
     d=max(c)
     if l.count(d)>2:
          print(sum(l)-3*d)
     elif l.count(d)==2:
          print(sum(l)-2*d)
else:
     print(sum(l))

def test(a,x):
    i,aux=0,0
    for i in range(5):
        if a[i]==x:
            aux+=1
    return aux
a=raw_input()
a=a.split(' ')
s=[]
i=0
for i in range(5):
    s.append(int(a[i],10))
aux=s[0]
for i in range(1,5):
    if s[i]*test(a,s[i])>aux*test(a,aux) :
        aux= s[i]
b=0
for i in range(5):
    b+=s[i]
b=b-(aux*test(a,aux))
print b

y=sorted(list(map(int,input().split())))
for i in range(1,len(y)):
        x= y.count(y[-i])
        if x>=2:
                print(sum(y)-y[-i]*x if x<=3 else sum(y)-y[-i]*3)
                exit()
print(sum(y))

a=input()
a=a.split()
a[0]=int(a[0])
a[1]=int(a[1])
a[2]=int(a[2])
a[3]=int(a[3])
a[4]=int(a[4])
a.sort()
b=a[0]
contador=0
for k in range (5):
    c=a.count(a[k])
    if c>=2 and a[k]>=b:
        b=a[k]
        contador=c
if contador>=3:
    a.remove(b)
    a.remove(b)
    a.remove(b)
    y=sum(a)
if contador==2:
    a.remove(b)
    a.remove(b)
    y=sum(a)
else:
    y=sum(a)
print(y)

l=input().split()
s=0
for i in range(5):
    l[i]=int(l[i])
    s+=l[i]

l.sort()
f=[]
i=4
cn=1
while(i>0):
    if(l[i]==l[i-1] and i!=1):
        cn+=1
    elif(l[i]==l[i-1] and i==1):
        cn+=1
        f.append([cn,s-cn*l[i]])
    else:
        if(cn>2):
            f.append([3,s-3*l[i]])
        else:
            f.append([cn,s-cn*l[i]])
        cn=1
    i-=1
mi=s
s=len(f)
for i in range(s):
    if((f[i][0]>1) and f[i][1]<mi):
        mi=f[i][1]
print(mi)

from collections import Counter

def unique(lst, p_number, p_count):
    count = 0
    seen = set()
    result = []
    for x in lst:
        if(count == p_count): break
        if p_number in seen:
            count += 1
            continue
        seen.add(x)
        result.append(x)
    return result

numbers = list(map(int,input().split()))

r_one = sum(numbers)

count = 0

number = -1
c = Counter(numbers)
d = dict(c)
max_numbers = numbers[:]
while not (count >= 3) and len(max_numbers) != 0:
    ma_x = max(max_numbers)
    number = ma_x
    max_numbers.remove(number)
    count = d[ma_x]

r_two = 501
if(count >= 2):
    buff = numbers[:]
    buff.remove(number)
    buff.remove(number)
    r_two = sum(buff)
    #r_two = sum(unique(buff, number, 2))

r_three = 501
if(count >= 3):
    buff = numbers[:]
    buff.remove(number)
    buff.remove(number)
    buff.remove(number)
    r_three = sum(buff)
    #r_two = sum(unique(buff, number, 2))

print(min(r_one, r_two, r_three))

#!/usr/bin/python

a = raw_input ()
a = a . split ()
b = []
c = []
e = []
f = []
g = []
o = []

if len (a) == 5 :

    for x in a :

        x = int (x)
        if 1 <= x <= 100 :
            e.append (x)
            o.append (x)
        else :
            quit ()

    for x in o :

        if o.count (x) >= 3 :
            if x not in b :
                while len (b) != 3 :
                    e.pop (e.index(x))
                    b.append (x)
                f . append ( sum (e) )
                e = o
            b = []

        elif o.count (x) == 2 :
            if x not in c :
                while len (c) != 2 :
                    e.pop (e.index(x))
                    c.append (x)
                if len (g) == 2 :
                    break
                g . append ( sum (e) )
                e = o
            c = []

    if len (f) != 0 :
        h = min (f)
    else :
        h = 0

    if len (g) != 0 :
        j = min (g)
    else :
        j = 0

    if h != 0 and j != 0 :
        print min ( h , j )
    elif h == 0 and j != 0 :
        print j
    elif h != 0 and j == 0 :
        print h
    else :
        print sum (o)

x1=input().split()
l1=[]
for i in x1:
    i=int(i)
    l1.append(i)
sum1=100000000000
l2=l1.copy()
for i in l2:
    c=0
    l1=l2.copy()
    z=l1.count(i)
    if z>1:
        if z>3:
            z=3
            while c<z:
                l1.remove(i)
                c+=1
    y=sum(l1)
    if sum1>y:
        sum1=y
print(sum1)

from collections import defaultdict

t = list(map(int, input().split()))
d = defaultdict(int)
s = sum(t)

for x in t:
    d[x] += 1

ans = s

for x, y in d.items():
    if y not in (2, 3):
        continue
    if s - x * y < ans:
        ans = s - x * y
print(ans)

def cnt(s,v):
    ans=0
    for i in s:
        if i==v:
            ans+=1
    return ans

s=[int(z) for z in input().split()]
mx=0
for i in range(1000):
    mx=max(mx,max(cnt(s,i),3)*i)
print(sum(s)-mx)

a=map(int,raw_input().split())
a.sort()
a.reverse()
x=sum(a)
for i in a:
	if a.count(i)>=3:
		x-=3*i
		break
	elif a.count(i)==2:
		x-=2*i
		break
print x

__author__ = 'Enmanuel Medina'
import sys

line = raw_input()
arr = [int(x) for x in line.split()]
size = len(arr)
arr.sort(None, None, True)
cnt = 1
Narr = []
temp = False
ans = 0

for x in range(1, size):
    if arr[x - 1] == arr[x]:
        cnt += 1
    else:
        Narr.append([arr[x - 1], cnt])
        cnt = 1

if cnt != 1:
    Narr.append([arr[size - 2], cnt])
if arr[size - 1] != arr[size - 2]:
    Narr.append([arr[size - 1], 1])

size = len(Narr)
for pos in xrange(0, len(Narr)):
    if temp is True:
        temp = False
        continue
    if Narr[pos][1] == 1:
        ans += Narr[pos][0]
    elif Narr[pos][1] > 3:
        ans += Narr[pos][0]*(Narr[pos][1] - 3)
    elif pos < size - 1:
        if Narr[pos][0]*Narr[pos][1] > Narr[pos + 1][0]*Narr[pos + 1][1]:
            ans += Narr[pos + 1][0]*Narr[pos + 1][1]
        else:
            ans += Narr[pos][0]*Narr[pos][1]
        temp = True

print ans

arr = [int(x) for x in input().split()]
d={}
for i in arr:
    d[i] = d.get(i,0) +1
if len(d)==5:
    print(sum(d.keys()))
else:
    a = []
    total = 0
    for i in d:
        if d[i]==1:
            total += i
        elif d[i]<4:
            a.append(i*d[i])
        else:
            a.append((d[i]-3)*i)
    a.sort()
    total += a[0]
    print(total)

vlist=[int(x) for x in raw_input().split()]
vlist.sort()
last=x
num=1
mi=0
for x in vlist:
    num += 1
    if x==last and num<=3:
        mi=max(mi,x*num)
        num+=1
    else:
        num=1
    last=x
print sum(vlist)-mi

arr=[int(i) for i in input().split()]
hsh=[0 for i in range(0,101)]
arr.sort()
for i in arr:
    hsh[i]+=1
i=4
while i>=1:
    if hsh[arr[i]]>=3:
        hsh[arr[i]]-=3
        break
    elif hsh[arr[i]]>=2:
        hsh[arr[i]]-=2
        break
    i-=1
ans=0
i=0
for i in range(0,101):
    ans+=hsh[i]*i
print(ans)

l=input().split()
s=0
for i in range(5):
    l[i]=int(l[i])
    s+=l[i]

l.sort()
f=[]
i=4
cn=1
while(i>0):
    if(l[i]==l[i-1] and i!=1):
        cn+=1
    else:
        if(cn>2):
            f.append([3,s-3*l[i]])
        else:
            f.append([cn,s-cn*l[i]])
        cn=1
    i-=1
mi=s
s=len(f)
for i in range(s):
    if((f[i][0]>1) and f[i][1]<mi):
        mi=f[i][1]
print(mi)

arr = [int(x) for x in input().split()]
d={}
for i in arr:
    d[i] = d.get(i,0) +1
if len(d)==5:
    print(sum(d.keys()))
else:
    a = []
    total = 0
    for i in d:
        if d[i]==1:
            total += i
        elif d[i]<4:
            a.append(i*d[i])
        else:
            a.append(2*i)
    a.sort()
    total += a[0]
    print(total)

t = list(map(int, input().split()))

c = {0: 1}
for e in t:
    if c.get(e) is None:
        c[e] = 1
    else:
        c[e] += 1

cand = [0]
for k in c.keys():
    if c[k] > 1:
        cand.append(k)

r = max(cand)
print(sum(t) - min(3, c[r]) * r)

lst = list(map(int, input().split()))
data = [0] * 101
s = 0
for i in lst:
    data[i] += 1
    s += i
max_change = 0
for i in range(101):
    if data[i] > 2:
        max_change = max(max_change, i * 3)
    if data[i] > 1:
        max_change = max(max_change, i * 2)
    elif data[i] > 0:
        max_change = max(max_change, i)
print(s - max_change)

from collections import defaultdict
l = list(map(int, input().split()))
d = defaultdict(int)
t = sum(l)
for li in l:
    d[li] += 1
s3 = s2 = None
for k in d:
    if d[k] >= 3:
        s3 = 3*k
    elif d[k] == 2:
        s2 = 2*k
if s2 != None and s3 != None:
    t -= (s2 if s2 > s3 else s3)
elif s2 != None:
    t -= s2
elif s3 != None:
    t -= s3
print(t)

string = input()
lst = string.split()
for index in range(len(lst)) :
    lst[index] = int(lst[index])
lst2 = []
for num in lst :
    if num not in lst2 :
        lst2.append(num)
if len(lst2) == 1 :
    print(lst2[0] * 2)
elif len(lst2) == 2 :
    temp = sum(lst)
    df = 0
    for num in lst :
        if lst.count(num) == 3 :
            df = num
    Max = 0
    for num in lst :
        if lst.count(num) == 2 :
            if num > Max :
                Max = num
    if temp - df * 3 > temp - Max * 2 :
        print(temp - df * 3)
    else :
        print(temp - Max * 2)
elif len(lst2) == 4 :
    print(sum(lst2))
elif len(lst2) == 5 :
    print(sum(lst2))
else :
    temp = sum(lst)
    Max = 0
    for num in lst :
        if lst.count(num) == 2 :
            if num > Max :
                Max = num
    print(temp - Max * 2)

arr = map(int, raw_input().split())

arr.sort()

z = [0]*(100+1)

for i in arr:
        z[i]+=1

s = sum(arr)
a,b,c,d = 0,0,0,0
if 3 in z or 4 in z or 5 in z:
        i = 100
        while i>=0:
                if z[i]>=3:
                        break
                i-=1
        a = i*3
else:
        i = 100
        while i>=0:
                if z[i]>=2:
                        break
                i-=1
        b = i*2

print s-max(a,b)

a=list(map(int,input().split()))
a.sort(reverse=True)
p_ans=0
for i in range(len(a)-1):
	if a[i]==a[i+1]:
		if i!=0:
			if a[i]==a[i-1]:
				c=3*a[i]
				if p_ans<c:
					p_ans=c
				else:
					continue
			else:
				c=2*a[i]
				if p_ans<=c:
					p_ans=c
				else:
					continue
	else:
		continue
print(sum(a)-p_ans)

d = {}

t = list(map(int, input().split()))
s = sum(t)
if len(set(t)) == 1:
  l = len(t)
  if l >= 3:
    print(s - (t[0]*3))
  else:
    print(s - (t[0]*l))
else:
  for i in t:
    if i not in d:
      d[i] = 1
    else:
      d[i] += 1
  d = sorted(d.items(), key = lambda x: (x[1], x[0]), reverse = True)
  d = list(filter(lambda x: x[1] == 2 or x[1] == 3, d))
  if len(d) == 0:
    print(s)
  else:
    print(s-(d[0][0]*d[0][1]))

cards = input().split()
cards = [int(x) for x in cards]
cards = sorted(cards, reverse=True)
lowest_sum = []
tokens = 1
counter = 1
for num in cards:
    if counter >= len(cards):
        break
    else:
        if num == cards[counter] and tokens <= 3:
            lowest_sum.append(num)
            if cards[counter] != cards[counter + 1]:
                lowest_sum.append(cards[counter])
    tokens += 1
    counter += 1

card_sum = sum(cards) - sum(lowest_sum)
print(card_sum)

# 680A : BEAR AND FIVE CARDS
# Prerequisite : Implementation

t1,t2,t3,t4,t5=(map(int,raw_input().split()))
a=[t1,t2,t3,t4,t5]
a.sort()
a.reverse()
total=sum(a)
final=0
if a[0]==a[1]:
    subtract=a[0]+a[1]
    if a[1]==a[2]:subtract+=a[2]
    final=max(subtract,final)
elif a[1]==a[2]:
    subtract=a[1]+a[2]
    if a[2]==a[3]:subtract+=a[3]
    final = max(subtract, final)
elif a[2]==a[3]:
    subtract=a[2]+a[3]
    if a[3]==a[4]:subtract+=a[4]
    final = max(subtract, final)
elif a[3]==a[4]:
    subtract=(a[3]+a[4])
    final = max(subtract, final)
print total-final

l = list(map(int,input().split()))

r = max(x * max(3,l.count(x)) for x in l if l.count(x) >= 2)
print (sum(l) - r)

from collections import defaultdict

t = list(map(int, input().split()))
d = defaultdict(int)
s = sum(t)

for x in t:
    d[x] += 1

ans = s

for x, y in d.items():
    if y not in (2, 3):
        continue
    if s - x * y < ans:
        ans = s - x * y
print(ans)

import sys
import math

#to read string
get_string = lambda: sys.stdin.readline().strip()
#to read list of integers
get_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )
#to read non spaced string and elements are integers to list of int
get_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))
#to read non spaced string and elements are character to list of character
get_charList_from_str = lambda: list(sys.stdin.readline().strip())
#get word sepetared list of character
get_char_list = lambda: sys.stdin.readline().strip().split()
#to read integers
get_int = lambda: int(sys.stdin.readline())
#to print faster
pt = lambda x: sys.stdout.write(str(x))

#--------------------------------WhiteHat010--------------------------------#
lst = get_int_list()
s = sum(lst)
m = max(lst, key = lambda x: (lst.count(x)*x))
if lst.count(m) >= 3:
    print(s-3*m)
elif lst.count(m) == 2:
    print(s-2*m)
else:
    print(s)

a=list(map(int,input().split()))
b=sorted(a)
ans1=ans2=0
for i in reversed(b):
    if a.count(i)>=3:
        ans1=i*3

    elif a.count(i)==2:
        ans2=i*2

print(sum(a)-max(ans1,ans2))

# import sys
# sys.stdin=open("input1.in","r")
# sys.stdout=open("output2.out","w")
L=list(map(int,input().split()))
L.sort(reverse=True)
X=0
for i in range(3):
	count=0
	for j in range(i,5):
		if L[i]==L[j]:
			count+=1
	if count>=2:
		X=count*L[i]
		i=j
print(sum(L)-X)

#!/usr/bin/python

a = raw_input ()
a = a . split ()
b = []
c = []
e = []
f = []
g = []
o = []

if len (a) == 5 :

    for x in a :

        x = int (x)
        if 1 <= x <= 100 :
            e.append (x)
            o.append (x)
        else :
            quit ()

    for x in o :

        if o.count (x) >= 3 :
            if x not in b :
                while len (b) != 3 :
                    e.pop (e.index(x))
                    b.append (x)
                f . append ( sum (e) )
                e = o
            b = []

        elif o.count (x) == 2 :
            if x not in c :
                while len (c) != 2 :
                    e.pop (e.index(x))
                    c.append (x)
                g . append ( sum (e) )
                e = o
            c = []

    if len (f) != 0 :
        h = min (f)
    else :
        h = 0

    if len (g) != 0 :
        j = min (g)
    else :
        j = 0

    if h != 0 and j != 0 :
        print min ( h , j )
    elif h == 0 and j != 0 :
        print j
    elif h != 0 and j == 0 :
        print h
    else :
        print sum (o)

import sys
import math

#to read string
get_string = lambda: sys.stdin.readline().strip()
#to read list of integers
get_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )
#to read non spaced string and elements are integers to list of int
get_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))
#to read non spaced string and elements are character to list of character
get_charList_from_str = lambda: list(sys.stdin.readline().strip())
#get word sepetared list of character
get_char_list = lambda: sys.stdin.readline().strip().split()
#to read integers
get_int = lambda: int(sys.stdin.readline())
#to print faster
pt = lambda x: sys.stdout.write(str(x))

#--------------------------------WhiteHat010--------------------------------#
lst = get_int_list()
s = sum(lst)
m = max(lst, key = lst.count)
if lst.count(m) >= 3:
    print(s-3*m)
elif lst.count(m) == 2:
    print(s-2*m)
else:
    print(s)

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Summarize count of factor within list -- START --
def summarizeList(l):
  sl=sorted(l,key=lambda x:x,reverse=True)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res
# Summarize count of factor within list --- END ---

def main():
  l=LI()
  sm=sum(l)

  sl=summarizeList(l)

  for x,c in sl:
    if c>1:
      if c>2:
        sm-=x*3
      else:
        sm-=x*2
      break

  return sm

# main()
print(main())

a=list(map(int, input().split()))
b={};sum=0

for i in a:
	if i not in b:
		b[i]=1
	else:
		b[i]+=1
p=[]
for i, j in b.items():
	if j==1:
		sum+=i
	elif j==5:
		sum+=i*2
	else:
		p+=[i*j]
if len(p)>1:
	sum+=min(p)
print(sum)

def test(a,x):
    i,tmp=0,0
    for i in range(5):
        if s[i]==x:
            tmp+=1
    return tmp
a=raw_input()
a=a.split(' ')
s=[]
i=0
for i in range(5):
    s.append(int(a[i],10))
aux=0
for i in range(5):
    if (s[i]*test(a,s[i])>aux*test(a,aux))&(2<= test(a,s[i])) :
        aux= s[i]
b=0
tmp=test(a,aux)
for i in range(5):
    b+=s[i]
if 3<=test(a,aux):
    tmp-=2
b=b-(aux*tmp)
print b

l = list(map(int,input().split()))
z = []
if len(set(l)) == len(l):
    print(sum(l))

else:
    for i in set(l):
        if l.count(i) > 1:
            z.append(i*l.count(i))
    print(sum(l)-max(z))

cards=list(map(int,input().split()))
c=0
for i in cards:
	if cards.count(i)in{2, 3} and i*cards.count(i)>c:
		if cards.count(i)>3:
			c=i*3
		else: c=i*cards.count(i)

print (sum(cards)-c)

def test(a,x):
    i,aux=0,0
    for i in range(5):
        if a[i]==x:
            aux+=1
    return aux
a=raw_input()
a=a.split(' ')
s=[]
i=0
for i in range(5):
    s.append(int(a[i],10))
aux=s[0]
for i in range(1,5):
    if s[i]*test(a,s[i])>aux*test(a,aux) :
        aux= s[i]
b=0
for i in range(5):
    b+=s[i]
b=b-(aux*test(a,aux))
print b

l=[int(x) for x in input().split()]
if len(set(l))==5:
    print(sum(l))
elif len(set(l))==1:
    print(2*l[0])
elif len(set(l))==2:
    q=[]
    s=0
    x=0
    for i in range(5):
        if l.count(l[i])==4:
            x=l[i]
        else:
            s+=l[i]
    s+=x
    #q.append(s)
    #print(x)
    if x!=0:
        #print("hi")
        print(s)
    else:
        #q.append(sum(set(l)))
        x=max(set(l))
        q.append(l.count(x)*x)
        x=min(set(l))
        q.append(l.count(x)*x)

        print(min(q))
else:
    q=[]
    q.append(sum(l))
    m=[]
    for i in range(5):
        if l.count(l[i])==2 and i not in m:
            m.append(i)
    #print(len(m))
    if len(m)==4:
        x=l.index(max(l[m[0]],l[m[1]]))
        s=0
        for i in range(5):
            if l[i]!=l[x]:
                s+=l[i]
        q.append(s)
    s=0
    for i in range(5):
        if l.count(l[i])!=3:
            s+=l[i]
    q.append(s)
    print(min(q))

from sys import stdin, stdout

ns = [int(x) for x in stdin.readline().rstrip().split()]
cs = dict()
m3 = 0
m2 = 0
s = 0
for i in ns:
    if cs.has_key(i):
        cs[i] += 1
        if cs[i] == 3 and i > m3:
            m3 = i
        if cs[i] == 2 and i > m2:
            m2 = i
    s+= i

m3 = s - m3*3
m2 = s - m2*2

stdout.write(str(m3 if m3 <m2 else m2))

def sum(a):
    s=0
    for i in a:
        s=s+i
    return s
a=list(map(int,input().split()))
a.sort()
b=list(set(a))
b.sort()
i=0
d=[]
c=[]
x=sum(a)
if len(a)==len(b):
    print(x)
else:
    while len(a)!=0:
        if a[0]==b[0]:
            c.append(a[0])
            del (a[0])
            if len(c)>3:
                del(c[len(c)-1])
                d.append(c)
                c=[]
        else:
            if len(c)<=3 and len(c)>1:
                d.append(c)
            del(b[0])
            c=[]
    z=[]
    for i in range(len(d)):
        z.append(x-sum(d[i]))
    print(min(z))

t = map(int, raw_input().split())
ans = 0
for i in t:
	k = t.count(i)
	if(k>=2):
		ans = max(ans,k*i)
print sum(t)-ans

l=input().split()
s=0
for i in range(5):
    l[i]=int(l[i])
    s+=l[i]

l.sort()
f=[]
i=4
cn=1
while(i>0):
    if(l[i]==l[i-1] and i!=1):
        cn+=1
    else:
        if(cn>2):
            f.append([3,s-3*l[i]])
        else:
            f.append([cn,s-cn*l[i]])
        cn=1
    i-=1
mi=s
s=len(f)
for i in range(s):
    if((f[i][0]>1) and f[i][1]<mi):
        mi=f[i][1]
print(mi)

cards = map(int, raw_input().split(" "))

card_freq = [0] * 101
for card in cards:
    card_freq[card] += 1

max_discard = 0
for i in range(1, len(card_freq)):
    freq = card_freq[i]
    if (freq == 2 or freq == 3) and card_freq[i] > max_discard:
        max_discard = i * card_freq[i]

print sum(cards) - max_discard

line = raw_input()
a = map(int, line.split(' '))
a = sorted(a)

k = 2
S = a[0]
max_sum = 0
current_sum = a[0]
for i in xrange(1, 5):
    S += a[i]
    if a[i] == a[i-1] and k <= 3:
        k += 1
        current_sum += a[i-1]
        if current_sum > max_sum:
            max_sum = current_sum
    else:
        k = 1
        current_sum = a[i]

print(S - max_sum)

t = list(map(int, input().split()))
tmp = 0
for i in t:
    if t.count(i) >= 3:
        print(i * 2)
        exit()
    if t.count(i) == 2:
        if tmp < i:
            tmp = i
print(sum(t) - (tmp * 2))

# CodeForcesian
# ♥
# یا امام رضا

string = input()
lst = string.split()
for index in range(len(lst)) :
    lst[index] = int(lst[index])
lst2 = []
for num in lst :
    if num not in lst2 :
        lst2.append(num)
if len(lst2) == 1 :
    print(lst2[0] * 2)
elif len(lst2) == 2 :
    temp = sum(lst)
    for num in lst :
        if lst.count(num) == 3 :
            three = num
    two = 0
    for num in lst :
        if lst.count(num) == 2 :
            if num > two :
                two = num
    if temp - three * 3 < temp - two * 2 :
        print(temp - three * 3)
    else :
        print(temp - two * 2)
elif len(lst2) == 4 :
    print(sum(lst2))
elif len(lst2) == 5 :
    print(sum(lst2))
else :
    temp = sum(lst)
    Max = 0
    for num in lst :
        if lst.count(num) == 2 :
            if num > Max :
                Max = num
    print(temp - Max * 2)

from collections import Counter
arr = ['0']
l = map(int,raw_input().split())
k = set([x for x in l if l.count(x) > 1])
j = set([x for x in l if l.count(x) == 1])
t=0
for i in k:
    arr.append(i)
k = min(arr)
k1 = max(arr)
c = l.count(k)
if c==2:
    k=k*2
elif c==3:
    if(k*3 > k1*2):
        k=k1*2
    else:
        k=k*3
else:
    k=0
if(l[0]==l[1]==l[2]==l[3]==l[4]):
    k=arr[1]*2
for n in j:
    t=t+n
print t+k

t=list(map(int,input().split(' ')))
t.sort()
s=set(t)
summ=sum(t)
a=[]
if len(s)==1:
    print(2*t[0])
elif len(s)==2:
    if t[1]==t[2] and t[2]==t[3]:
        print(summ-3*t[1])
    else:
        print(summ-max(3*t[2],2*t[0],2*t[4]))
elif len(s)==3:
    for j in range(0,4):
        if t[j]==t[j+1]:
            a.append(t[j])
    summ-=2*max(a)
    print(summ)
elif len(s)==4:
    for j in range(0,4):
        if t[j]==t[j+1]:
            summ-=2*t[j]
    print(summ)
else:
    print(summ)

from collections import Counter
A = map(int, raw_input().split())
C = Counter(A)
Th = filter(lambda x: C[x]==3 ,C)
Tw = filter(lambda x: C[x]==2 ,C)
if Th and Tw:
	print sum(A) - max(Th[0]*3, Tw[0]*2)
elif Th:
	print sum(A) - Th[0]*3
elif Tw:
	print sum(A) - max(Tw)*2
else:
	print sum(A)

arr = list(map(int, input().split()))

counts = dict()
mx = -1

for i in arr:
    if i in counts:
        counts[i] += 1
        if counts[i] >= 2:
            mx = max(mx, i)
    else:
        counts[i] = 1

if mx != -1:
    print(sum(arr) - mx * min(counts[mx], 3))
else:
    print(sum(arr))

# -*- coding: utf-8 -*-
from collections import Counter

cards = map(int, raw_input().split())
c = Counter(cards)

c = c.most_common(5)
if len(c) == 5:
    print(sum(cards))
    exit(0)

_max = 0
for card, _count in c:
    if _count in [2, 3]:
        _max = max(_max, card * min(_count, 3))

print(sum(cards) - _max)

li = map(int,raw_input().split())
tot = sum(li)
m1 = 0
di = {}
for ele in li:
	if ele in di:
		di[ele] += 1
	else:
		di[ele] = 1
	m1 = max(m1,ele)

for ele in li:
	m1 = max(m1,min(3,di[ele])*ele)

print tot-m1

a = list(map(int, input().split()))
b = [0]*101

for x in a:
    b[x] += 1

for i in range(100, 0, -1):
    if b[i] >= 3:
        b[i] -= 3
        break
    if b[i] >= 2:
        b[i] -= 2
        break

print(sum(i*x for i, x in enumerate(b)))


IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is not divisible by any number from 2 to 10 every developer of this game gets a small bonus.A game designer Petya knows that the company is just about to release a new game that was partly developed by him. On the basis of his experience he predicts that n people will buy the game during the first month. Now Petya wants to determine how many times he will get the bonus. Help him to know it.

The only line of the input contains one integer n (1 ≤ n ≤ 1018) — the prediction on the number of people who will buy the game.

Output one integer showing how many numbers from 1 to n are not divisible by any number from 2 to 10.

#!/usr/bin/python3
# Copyright (C) 2016 Sayutin Dmitry.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; version 3
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; If not, see <http://www.gnu.org/licenses/>.

theset = [2, 3, 5, 7]
def brute(cur, i, n):
    res = 0
    if i < len(theset):
        res += brute(cur, i + 1, n)
        cur.append(theset[i])
        res += brute(cur, i + 1, n)
        cur.pop()
    else:
        k = 1
        for elem in cur:
            k *= elem
        res += (+1 if len(cur) % 2 == 0 else -1) * (n // k)
    return res

n = int(input())
print(brute([], 0, n))

def f(x):
	re = 0
	for i in range(1, x + 1):
		flag = True
		for j in range(2, 11):
			if i % j == 0:
				flag = False
				break
		if flag:
			re += 1
	return re

n = input()
print f(2520) * (n / 2520) + f(n % 2520)

LCM=2520
sieve=[1]*LCM;sieve[0]=0
for i in range(2,10):
	for j in range(i,LCM,i):
		sieve[j]=0
n=int(input())
print(sum(sieve)*(n//LCM)+sum(sieve[:n%LCM+1]))

pls = 0
arr = [None]*210
for i in xrange(1,211):
	arr[i-1] = (i%2!=0 and i%3!=0 and i%5!=0 and i%7!=0)
	pls += 1 if arr[i-1] else 0

n = input()
plox = 0
for i in xrange(n%210):
	plox += 1 if arr[i] else 0
ans = (n/210)*pls + plox
print(ans)

def test(x):
    return not any([x%i==0 for i in list(range(2,11))])
N = int(input())
CP = 2**3*3**2*5*7
toCP = 0

for i in range(1, CP+1):
    if test(i):
        toCP+=1

ans = int(N/CP)*toCP
for i in range((int(N/CP)*CP)+1,N+1):
    if test(i):
        ans+=1
print(ans)

n = int(raw_input())
cnt = 0
def check(num):
    for i in xrange(2, 11):
        if num % i == 0: return False
    return True
for i in xrange(1, 2520):
    if check(i): cnt += 1
res = n / 2520 * cnt
n %= 2520
for i in xrange(1, n + 1):
    if check(i): res += 1
print res

n = (int)(input())
p = [2, 3, 5, 7]

d = 0
for i in p:
  d += n // i

for i in range(0, 3):
  for j in range(i + 1, 4):
    d -= n // (p[i] * p[j])

for i in range(0, 2):
  for j in range(i + 1, 3):
    for k in range(j + 1, 4):
      d += n // (p[i] * p[j] * p[k])

d -= n // 210

print(n - d)

# IDEA : Principle of inclusion and exclusion
from math import sqrt
n = input()
temp = n/2 + n/3 + n/5 + n/7
temp -= (n/6 + n/10 + n/14 + n/15 + n/21 + n/35)
temp += (n/30 + n/42 + n/105 + n/70)
temp -= n/210
ans = n - temp
print ans

import math
from math import *
n = int(input())
d = [2,3,5,7]
ans = n
for i in range(4):
    ans -= n//d[i]
for i in range(4):
    for j in range(i+1,4):
        ans += n//(d[i]*d[j])
for i in range(4):
    for j in range(i+1,4):
        for k in range(j+1,4):
            ans -= n//(d[i]*d[j]*d[k])
ans += n//(2*3*5*7)
print(ans)

#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys, math, random, operator
from string import ascii_lowercase
from string import ascii_uppercase
from fractions import Fraction, gcd
from decimal import Decimal, getcontext
from itertools import product, permutations, combinations
from Queue import Queue, PriorityQueue
from collections import deque, defaultdict, Counter
getcontext().prec = 100

MOD = 10**9 + 7
INF = float("+inf")

if sys.subversion[0] != "CPython":  # PyPy?
    raw_input = lambda: sys.stdin.readline().rstrip()
pr = lambda *args: sys.stdout.write(" ".join(str(x) for x in args) + "\n")
epr = lambda *args: sys.stderr.write(" ".join(str(x) for x in args) + "\n")
die = lambda *args: pr(*args) ^ exit(0)

read_str = raw_input
read_strs = lambda: raw_input().split()
read_int = lambda: int(raw_input())
read_ints = lambda: map(int, raw_input().split())
read_float = lambda: float(raw_input())
read_floats = lambda: map(float, raw_input().split())

"---------------------------------------------------------------"

n = read_int()
res = []
for i in range(2520):
    for j in range(2, 11):
        if i % j == 0:
            break
    else:
        res.append(1)
        continue
    res.append(0)

q, r = divmod(n, 2520)
ans = q * res.count(1) + res[:r + 1].count(1)
print ans

n = int(input())
primes = [2, 3, 5, 7]
ans = 0
for msk in range(1 << len(primes)):
    p = 1
    sign = 1
    for i in range(len(primes)):
        if (msk & (1 << i)):
            p *= primes[i]
            sign *= -1
    ans += (n // p) * sign
print(ans)

n = int(input())
a = n // 2
b = n // 3
c = n // 5
d = n // 7
ab = n // 6
ac = n // 10
ad = n // 14
bc = n // 15
bd = n // 21
cd = n // 35
abc = n // 30
abd = n // 42
acd = n // 70
bcd = n // 105
abcd = n // 210
rest = a + b + c + d - ab - ac-ad-bc-bd-cd + abc + abd + acd + bcd - abcd
print(n - rest)

from math import *
from fractions import gcd
from itertools import combinations
n = int(raw_input())

ans = 0

arr = [i + 2 for i in xrange(9)]

for r in xrange(0, len(arr) + 1):
    for mask in combinations(arr, r):
        l = 1
        for i in mask:
            l = l / gcd(i, l) * i
        ans += n / l if r % 2 == 0 else -(n / l)

print ans

from pdb import *
def	gcd(x,y):
	a=x; b=y; c=a%b;
	while c:
		a=b;b=c;c=a%b;
	return b
n=input()
Sum=0
for i in range(1,1<<9):
	cnt=0
	t=1
	for j in range(9):
		if i&(1<<j):
			t=t*(j+2)/gcd(t,j+2)
			cnt+=1
	if t==0 :continue
	if cnt%2:Sum+=n/t
	else    :Sum-=n/t
print n-Sum

n = int(input())
A = [2, 3, 5, 7]
p = 4

ans = 0
for i in range(1 << p):
    now, cnt = 1, 0
    for j in range(p):
        if (i >> j & 1):
            now *= A[j]
            cnt += 1
    if (cnt % 2):
        ans -= n // now
    else:
        ans += n // now
print(ans)

import os, sys, pdb
import time, calendar, datetime
import math, itertools
import operator as op
from functools import reduce

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

l = []
for i in range(2520):
    div = 1
    for j in range(2,11):
        if i % j == 0:
            div = 0
    l.append(div)

#print(l[:15])

n, = list(map(int, input().split()))

#for n in range(10000):
ans = ( (n // 2520) * sum(l) + sum(l[:(n % 2520)+1]) )
print(ans)

'''
    slow = 0
    for i in range(n+1):
        div = 1
        for j in range(2,11):
            if i % j == 0: div = 0
        slow += div

    if ans != slow:
        print(n, ans, slow)
'''

n = int(raw_input())
a = []
for i in xrange(2520):
    ok = False
    for j in xrange(2, 11):
        if i % j == 0:
            ok = True
    a.append(0 if ok else 1)

s = [0]
for i in xrange(2520):
    s.append(s[-1] + a[(i + 1) % 2520])

print n // 2520 * s[2520] + s[n % 2520]

s = raw_input()
l = s.split(" ")
n = long(l[0])

res = 0

res += n / 1

res -= n / 2
res -= n / 3
res -= n / 5
res -= n / 7

res += n / 6
res += n / 15
res += n / 35
res += n / 10
res += n / 21
res += n / 14

res -= n / 30
res -= n / 42
res -= n / 70
res -= n / 105

res += n / 210

print res

n=int(raw_input())
ans=n
ans-=n/2
ans-=n/3
ans-=n/5
ans-=n/7

ans+=n/6
ans+=n/10
ans+=n/14
ans+=n/15
ans+=n/21
ans+=n/35

ans-=n/30
ans-=n/42
ans-=n/70
ans-=n/105

ans+=n/210

print ans

M = 2 * 3 * 5 * 7
v = [0] * M
for i in range(1, M):
    v[i] = v[i - 1] + bool(i % 2 and i % 3 and i % 5 and i % 7)
n = int(input())
print(n // M * v[-1] + v[n % M])

n = int(input())

ans = n
p = [2, 3, 5, 7]
for i in range(1, 2**4):
    cnt = 0
    value = 1
    for s in range(4):
        if (i & (1 << s)) > 0:
            value *= p[s]
            cnt += 1
    sign = -1 if cnt % 2 == 1 else 1
    ans += sign * (n // value)
print(ans)

import sys
import math

f = sys.stdin

n = int(f.readline())
div2 = n // 2
div3 = n // 3
div5 = n // 5
div7 = n // 7

div6 = n // 6
div10 = n // 10
div14 = n // 14
div15 = n // 15
div21 = n // 21
div35 = n // 35

div30 = n // 30
div42 = n // 42
div70 = n // 70
div105 = n // 105

div210 = n // 210

print n-(div2+div3+div5+div7-div6-div10-div14-div15-div21-div35+div30+div42+div70+div105-div210)

import sys
from math import gcd
def read():
    return sys.stdin.readline().strip()
def printf(a, sep = ' ', end = '\n'):
    sys.stdout.write(sep.join(map(str, a)) + end)
    #printf([n])
def readf():
    return [int(i) for i in read().split()]
def main():
    n = int(read())
    ans = n
    p = [2, 3, 5, 7]
    ans -= n//2 + n//3 + n//5 + n//7
    ans += n//6 + n//10 + n//14 + n//21 + n//15 + n//35
    ans -= n//30 + n//42 + n//105 + n//70
    ans += n//210
    printf([ans])
main()

def cal():
	num = int(input().strip())
	nums = [2,3,5,7]
	cul2 = [6,10,14,30,210]
	cul3 = [15,105]
	cul5 = [35]
	ans=0
	for i in range(len(nums)):
		ans += (num//nums[i])
		if i == 0:
			for j in cul2:
				ans -= num//j
		if i == 1:
			for j in cul3:
				ans -= num//j
		if i == 2:
			for j in cul5:
				ans -= num//j

	print(num - ans)

n = int(input())
ost = n//210
ans = 0
for i in range(1, n%210 + 1):
    if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 or i % 7 == 0:
        ans += 1
print(ost * 48 + n - ans)

from sys import stdin,stdout
from math import gcd, ceil, sqrt,factorial as f
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007

n = ii1()
div = [2, 3, 5, 7]
res = n
for i in div:
    res -= n // i
div1 = [6, 10, 14, 30, 210, 15, 21, 105, 35, 42, 70]
for i in div1:
    res += n // i
print(res)

from sys import stdin
n = int(stdin.readline())
result = n - n//2 - n//3 - n//5  - n//7 + n//6 + n//10 + n//14 + n//15 + n//21 + n//35
print(result)

#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

from math import sqrt, floor, factorial, gcd, log
from collections import deque, Counter, defaultdict
from itertools import permutations
from math import gcd
from bisect import bisect

input = lambda: sys.stdin.readline().rstrip("\r\n")
read = lambda: list(map(int, input().strip().split(" ")))

def lcm(arr):
    _lcm = 1
    for i in arr:
        _lcm = (_lcm*i)//gcd(_lcm, i)
    return(_lcm)

def solve():
    n = int(input())
    primes = [2,3,5,7]
    ans = sum([n//i for i in primes])
    for i in range(4):
        for j in range(i+1, 4):
            ans -= n//lcm([primes[i], primes[j]])
    ans -= n//lcm(primes)
    print(abs(n - ans))

if __name__ == "__main__":
	solve()

def main():
    res, n = divmod(int(input()), 2520)
    l = [1] * n
    for p in range(2, 11):
        for i in range(0, n, p):
            l[i] = 0
    print(res * 576 + sum(l))

if __name__ == '__main__':
    main()

t=int(input())
a=t//2
b=t//3
c=t//5
d=t//7
ab=t//6
ac=t//10
ad=t//14
bc=t//15
bd=t//21
cd=t//35
abc=t//30
abd=t//70
acd=t//42
bcd=t//105
abcd=t//210
x=a+b+c+d+abc+abd+acd+bcd
y=ab+ac+ad+bc+bd+cd+abcd
print(x-y)

def test(x):
    return not any([x%i==0 for i in list(range(2,11))])
N = int(input())
CP = 2*3*5*7
toCP = 0

for i in range(1, CP+1):
    if test(i):
        toCP+=1

ans = int(N/CP)*toCP
for i in range(int(N/CP)*CP+1,N+1):
    if test(i):
        ans+=1
print(ans)

from math import *
from fractions import gcd
from itertools import combinations
n = int(raw_input())

ans = 0

arr = [i + 2 for i in xrange(9)]

for r in xrange(0, len(arr)):
    for mask in combinations(arr, r):
        l = 1
        for i in mask:
            l = l / gcd(i, l) * i
        ans += n / l if r % 2 == 0 else -(n / l)

print ans

n = int(input())

solution = int(n/2) + int(n/3) + int(n/5) + int(n/7)
solution -= (int(n/6) + int(n/10) + int(n/14) + int(n/15) + int(n/21) + int(n/35))
solution += int(n/30) + int(n/42) + int(n/70) + int(n/105)
solution -= int(n/210)

print(n - solution)

def sieve(n):
    s=[1]*(n+1)
    s[0]=0
    s[1]=0
    for i in range(2,n+1):
        if s[i]==1:
            for j in range(i*i,n+1,i):
                s[j]=0
    return s

def pi(x):
    s=sieve(x)
    for i in range(1,len(s)):
        s[i]=s[i]+s[i-1]
    return s

n=int(input())
if n==1:
    print(1)
elif 2<=n<=10:
    print(0)
else:
    print(-3 + pi(n)[-1])

from sys import stdin
n = int(stdin.readline())
result = n - n//2 + n//3 + n//5 + n//7
print(result)

#########			##	##     ##    	  ####  #####  ##     #  ##     #		##
	#			   # #	# #   # #		 #	  #	#	#  # #    #  # #    #	   # #
	#			  #  #	#  ###  #	    #		#	#  #  #   #  #  #   #	  #  #
	#			 #####	#	#	#	   #    ###	#	#  #   #  #  #   #  #    #####
	#			#    #	#		#	   #    # #	#	#  #	# #  #	  # #   #    #
######### 	   #     # 	#		#		##### #	#####  #	 ##  #	   ##  #     #

"""

PPPPPPP       RRRRRRR		    OOOO	  VV        VV    EEEEEEEEEE
PPPPPPPP      RRRRRRRR         OOOOOO     VV       VV	  EE
PPPPPPPPP     RRRRRRRRR       OOOOOOOO    VV      VV	  EE
PPPPPPPP      RRRRRRRR        OOOOOOOO    VV     VV    	  EEEEEE
PPPPPPP       RRRRRRR         OOOOOOOO    VV    VV        EEEEEEE
PP  		  RRRR			  OOOOOOOO    VV   VV         EEEEEE
PP			  RR  RR          OOOOOOOO    VV  VV          EE
PP			  RR    RR         OOOOOO     VV VV           EE
PP			  RR      RR        OOOO      VVVV            EEEEEEEEEE

"""

"""
 Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.
"""
import sys
input = sys.stdin.readline
# from bisect import bisect_left as lower_bound;
# from bisect import bisect_right as upper_bound;
# from math import ceil, factorial;

def ceil(x):
    if x != int(x):
        x = int(x) + 1
    return x

def factorial(x, m):
	val = 1
	while x>0:
		val = (val * x) % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp;

## gcd function
def gcd(a,b):
    if b == 0:
        return a;
    return gcd(b, a % b);

## lcm function
def lcm(a, b):
	return (a * b) // gcd(a, b)

## nCr function efficient using Binomial Cofficient
def nCr(n, k):
	if k > n:
		return 0
	if(k > n - k):
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

## upper bound function code -- such that e in a[:i] e < x;
def upper_bound(a, x, lo=0, hi = None):
    if hi == None:
        hi = len(a);
    while lo < hi:
        mid = (lo+hi)//2;
        if a[mid] < x:
            lo = mid+1;
        else:
            hi = mid;
    return lo;

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    primes = {}
    while(n%2 == 0 and n > 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0 and n > 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
def power(x, y, p):
    res = 1
    x = x % p
    if (x == 0) :
        return 0
    while (y > 0) :
        if ((y & 1) == 1) :
            res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b;

# find function with path compression included (recursive)
# def find(x, link):
#     if link[x] == x:
#         return x
#     link[x] = find(link[x], link);
#     return link[x];

# find function with path compression (ITERATIVE)
def find(x, link):
    p = x;
    while( p != link[p]):
        p = link[p];

    while( x != p):
        nex = link[x];
        link[x] = p;
        x = nex;
    return p;

# the union function which makes union(x,y)
# of two nodes x and y
def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
def sieve(n):
    prime = [True for i in range(n+1)]
    prime[0], prime[1] = False, False
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e5 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
spf = [0 for i in range(MAXN)]
# spf_sieve();
def factoriazation(x):
    res = []
    for i in range(2, int(x ** 0.5) + 1):
    	while x % i == 0:
    		res.append(i)
    		x //= i
    if x != 1:
   		res.append(x)
    return res
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()));

def float_array():
    return list(map(float, input().strip().split()));

## taking string array input
def str_array():
    return input().strip().split();

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################

from itertools import permutations
import math

from bisect import bisect_left

def solve():
	n = int(input())
	ans = n - (n // 2 + n // 3 + n // 5 + n // 7) + ( n // (2 * 3) + n // (2 * 5) + n // (2 * 7) + n // (3 * 5) + n // (3 * 7) * n // (5 * 7) ) - ( n // (2 * 3 * 5) + n // (2 * 3 * 7) + n // (2 * 5 * 7) + n // (3 * 5 * 7) ) + (n // (2 * 3 * 5 * 7))
	print(ans)
if __name__ == '__main__':
	for _ in range(1):
		solve()
	# fin_time = datetime.now()
# 	print("Execution time (for loop): ", (fin_time-init_time))

def yesorno (number):
    for i in range(11)[2:]:
        if (number%i) == 0:
            return 0
    return 1

countdownload = input()
countprem = 0
for number in range(countdownload+1):
    countprem += yesorno(number)
    print number
print countprem

def yesorno (number):
    for i in range(11)[2:]:
        if (number%i) == 0:
            return 0
    return 1

countdownload = input()
countprem = 1
for number in range(countdownload)[11::2]:
    countprem += yesorno(number)
print countprem

def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)

t=1

for i in xrange(2, 10):
    t= (t*i)/gcd(i, t)

n= int(raw_input())

print n-(n/t)

def pol(n,k):
    ans = 1
    for i in range(k):
        ans *= (n-i)/(i+1)
    k = int(ans)
    if abs(k - ans) < 1/2:
        return k
    return k + 1
n = int(input())
d = [2,3,5,7]
ans = n
for i in range(4):
    ans -= int(n/d[i])
for i in range(4):
    for j in range(4):
        if i < j:
            ans += int(n/(d[i]*d[j]))
for i in range(4):
    for j in range(4):
        for k in range(4):
            if i < j and j < k:
                ans -= int(n/(d[i]*d[j]*d[k]))

ans += int(n/(2*3*5*7))
print(ans)

import math
from math import *
n = int(input())
d = [2,3,5,7]
ans = n
for i in range(4):
    ans -= (n/d[i])
for i in range(4):
    for j in range(4):
        if i < j:
            ans += (n/(d[i]*d[j]))
for i in range(4):
    for j in range(4):
        for k in range(4):
            if i < j and j < k:
                ans -= (n/(d[i]*d[j]*d[k]))

ans += (n/(2*3*5*7))
print(int(ans))

import math
from math import *
n = int(input())
d = [2,3,5,7]
ans = n
for i in range(4):
    ans -= floor(n/d[i])
for i in range(4):
    for j in range(4):
        if i < j:
            ans += floor(n/(d[i]*d[j]))
for i in range(4):
    for j in range(4):
        for k in range(4):
            if i < j and j < k:
                ans -= int(n/(d[i]*d[j]*d[k]))

ans += floor(n/(2*3*5*7))
print(ans)

#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys, math, random, operator
from string import ascii_lowercase
from string import ascii_uppercase
from fractions import Fraction, gcd
from decimal import Decimal, getcontext
from itertools import product, permutations, combinations
from Queue import Queue, PriorityQueue
from collections import deque, defaultdict, Counter
getcontext().prec = 100

MOD = 10**9 + 7
INF = float("+inf")

if sys.subversion[0] != "CPython":  # PyPy?
    raw_input = lambda: sys.stdin.readline().rstrip()
pr = lambda *args: sys.stdout.write(" ".join(str(x) for x in args) + "\n")
epr = lambda *args: sys.stderr.write(" ".join(str(x) for x in args) + "\n")
die = lambda *args: pr(*args) ^ exit(0)

read_str = raw_input
read_strs = lambda: raw_input().split()
read_int = lambda: int(raw_input())
read_ints = lambda: map(int, raw_input().split())
read_float = lambda: float(raw_input())
read_floats = lambda: map(float, raw_input().split())

"---------------------------------------------------------------"

n = read_int()
res = []
for i in range(2520):
    for j in range(2, 11):
        if i % j == 0:
            break
    else:
        res.append(1)
        continue
    res.append(0)

q, r = divmod(n, 2520)
ans = q * res.count(1) + res[:r].count(1)
print ans

data = [2, 3, 5, 7]
n = int(input())
help = 0
for i in range(4):
    for j in range(4):
        if j > i:
            help += n // (data[i] * data[j])
print(n - (n // 2 + n // 3 + n // 5 + n // 7 - help))

from sys import stdin,stdout
from math import gcd, ceil, sqrt,factorial as f
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007

n = ii1()
div = [2, 3, 5, 7]
res = n
for i in div:
    res -= n // i
div1 = [6, 10, 14, 30, 210, 15, 21, 115, 35]
for i in div1:
    res += n // i
print(res)

# S = input()
# A = S[0] + S[2] + S[4] + S[3] + S[1]
# N = int(A)
# print(N ** 5 % 10 ** 5)

N = int(input())

sol = 0
primes = [2, 3, 5, 7]

for state in range(1, 2 ** len(primes)):

    numbBits = 0
    prod = 1

    for j in range(4):
        if (1 << j) & state:
            numbBits += 1
            prod *= primes[j]

    if numbBits & 1:
        sol += int(N / prod)
    else:
        sol -= int(N / prod)

print(N - sol)

import os, sys, pdb
import time, calendar, datetime
import math, itertools
import operator as op
from functools import reduce

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

l = []
for i in range(2520):
    div = 1
    for j in range(2,11):
        if i % j == 0:
            div = 0
    l.append(div)

#print(l[:15])

n, = list(map(int, input().split()))
print( (n // 2520) * sum(l) + sum(l[:((n+1) % 2520)]) )

def yesorno (number):
    for i in range(11)[2:]:
        if (number%i) == 0:
            return 0
    return 1

countdownload = input()
countprem = 0
for number in range(countdownload):
    countprem += yesorno(number)
print countprem

import math
from math import *
n = int(input())
d = [2,3,5,7]
ans = n
for i in range(4):
    ans -= int(n/d[i])
for i in range(4):
    for j in range(i+1,4):
        ans += int(n/(d[i]*d[j]))
for i in range(4):
    for j in range(i+1,4):
        for k in range(j+1,4):
            ans -= int(n/(d[i]*d[j]*d[k]))

ans += int(n/(2*3*5*7))
print(int(ans))

n = int(input())
ans = 0
s = [2, 3, 5, 7]
for i in s:
    ans += n // i
ans = n - ans + n // 6 + n // 10
print(ans)

num = int(input().strip())
nums = [2,3,5,7]
ans=0
for i in nums:
    ans += num//i
print(ans)