Problem:
 Score : 200 points    Problem Statement A shop sells N kinds of fruits, Fruit 1, \ldots, N , at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)  Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.      Constraints  1 \leq K \leq N \leq 1000  1 \leq p_i \leq 1000  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  K  p_1  p_2  \ldots  p_N       Output Print an integer representing the minimum possible total price of fruits.        Sample Input 1 5 3
50 100 80 120 80      Sample Output 1 210  This shop sells Fruit 1 , 2 , 3 , 4 , and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.  The minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1 , 3 , and 5 .       Sample Input 2 1 1
1000      Sample Output 2 1000

Solution (Python):
nk=input().split()
n=int(nk[0])
k=int(nk[1])
data=list(map(int,input().split()))
data.sort()
s=0
for i in range(k):
    s += data[i]
print(s)

Solution (Python):
N, K = map(int, input().split())
price_list = list(map(int, input().split()))

print(sum(sorted(price_list)[:K]))

Solution (Python):










































global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    
    
    N, K = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    
    
    
    
    
    
    

    values.sort()
    tmps = values[:K]
    result = sum(tmps)

    return [result]



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['5 3', '50 100 80 120 80']
        lines_export = [210]
    if pattern == 2:
        lines_input = ['1 1', '1000']
        lines_export = [1000]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())
p = [int(i) for i in input().split()]
p.sort()
print(sum(p[:k]))

Solution (Python):



N, K = map(int, input().split())
A = list(map(int, input().split()))
result = 0
for i in range(N):
    for j in range(i):
        if A[i-j-1] > A[i-j]:
            tmp = A[i-j]
            A[i-j] = A[i-j-1]
            A[i-j-1] = tmp

for i in range(K):
    result += A[i]

print(result)

Solution (Python):
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
print(sum(list(sorted(p))[0:K]))

Solution (Python):
n, k = map(int, input().split())
P = list(map(int, input().split()))
P = sorted(P)
ans = 0
for i in range(k):
    ans += P[i]
print(ans)

Solution (Python):
k, n = map(int, input().split())
prices = list(map(int, input().split()))
prices.sort()
total = sum(prices[:n])
print(total)

Solution (Python):
N, K = map(int, input().split())
x = list(map(int, input().split()))
y = sorted(x)
total = 0
for i in range(K):
  total += y[i]
print(total)

Solution (Python):
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))

P.sort()
sum = 0
for i in range(K):
    sum += P[i]
print(sum)

Solution (Python):
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))

def bubblesort(l):
    for index in range(len(l)-1, 0, -1):
        for low in range(index):
            if l[low] > l[low+1]:
                tmp = l[low+1]
                l[low+1] = l[low]
                l[low] = tmp
    return l

bubblesort(P)
sum = 0
for i in range(K):
	sum = sum + P[i]
print(sum)

Solution (Python):
n, k = [int(x) for x in input().split()]
lst = list(map(int, input().split()))

lst = sorted(lst)
print(sum(lst[:k]))

Solution (Python):
import sys


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

    N, K = map(int, readline().split())
    P = sorted([int(x) for x in readline().split()])

    print(sum(P[:K]))

resolve()

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
print(sum(sorted(p)[:k]))

Solution (Python):
n, k = map(int, input().split())
p = [int(i) for i in input().split()]
print(sum(sorted(p)[:k]))

Solution (Python):
import sys


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

    N, K = map(int, readline().split())
    P = [int(x) for x in readline().split()]

    P = sorted(P)

    print(sum(P[:K]))

resolve()

Solution (Python):
n,k=map(int, input().split())

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

print(sum(sorted(P)[:k]))

Solution (Python):
n,k = map(int,input().split())


p = [0 for _ in range(n)]
p = [int(s) for s in input().split()]
p.sort()

sm = 0
for i in range(k):
    sm += p[i]

print(sm)

Solution (Python):
import sys
N,K = map(int,input().split())
array = [ I for I in map(int,input().split()) if (1 <= I <= 1000) ]

if not ( 1 <= K <= N and K <= N <= 1000 ): sys.exit()

print(sum(sorted(array)[:K]))

Solution (Python):
_, k = map(int, input().split())
p = list(map(int, input().split()))

p = sorted(p)
print(sum(p[:k]))

Solution (Python):


def main():

    N, K = map(int, input().split())
    p = list(map(int, input().split()))

    ans = 0

    p.sort()
    

    for i in range(K):
        ans += p[i]

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
total,amount=[int(x) for x in input().split()]
array=sorted([int(x) for x in input().split()])
print(sum(array[0:amount]))

Solution (Python):
N, K=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
answer=0
for i in range(K):
  answer+=p[i]
print(answer)

Solution (Python):

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


l.sort()
ans = 0
for i in range(k):
    ans = ans + l[i]

print(ans)

Solution (Python):

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


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


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


def solve():
    N, K = map(int, input().split())
    P = list(sorted(list(map(int, input().split()))))

    ans = 0
    for i in range(K):
        ans += P[i]
    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())

A = list(map(int, input().split()))
A = sorted(A)
print(sum(A[:k]))

Solution (Python):
N,K = [int(s) for s in input().split()]
P = [int(s) for s in input().split()]
P.sort()
ans = sum(P[0:K])
print(ans)

Solution (Python):
_,K,*P=map(int,open(0).read().split())
print(sum(sorted(P)[:K]))

Solution (Python):
N, K = [int(s) for s in input().split()]
P = [int(s) for s in input().split()]

P.sort()

ans = sum(P[0:K])

print(ans)

Solution (Python):
import math
import sys
from collections import Counter
readline = sys.stdin.readline


def main():
    n, k = map(int, readline().rstrip().split())
    P = sorted(list(map(int, readline().rstrip().split())))
    print(sum(P[0: k]))


if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
print(sum(sorted(p)[:K]))

Solution (Python):


from typing import *
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, K: int, p: "List[int]"):
    return sum(sorted(p)[:K])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    p = [int(next(tokens)) for _ in range(N)]  
    print(solve(N, K, p))


if __name__ == '__main__':
    main()

Solution (Python):
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
nums.sort()

print(sum(nums[:k]))

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
ans = 0
for i in range(k):
  ans += p[i]
print(ans)

Solution (Python):
N,K=map(int,input().split())
p=[int(i) for i in input().split()]
p.sort()
ans=sum(p[0:K])
print(ans)

Solution (Python):
n,k=map(int,input().split())
p=sorted(list(map(int,input().split())))
num=0
for i in range(k):
    num+=p[i]
print(num)

Solution (Python):
N, K = map(int, input().split())
p = map(int, input().split())

print(sum(sorted(p)[:K]))

Solution (Python):
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

P.sort()



ans = sum(P[:K])
print(ans)

Solution (Python):
n, k = map(int, input().split())

data = list(map(int, input().split() ))
data.sort()
print(sum(data[0:k]))

Solution (Python):
n, k= map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:k]))

Solution (Python):
a,b=map(int,input().split())
n=list(map(int,input().split()))[:a]
n.sort()
sum=0

for i in range(b):
    sum+=n[i]

print(sum)

Solution (Python):
n,k=map(int,input().split())
prices = sorted(map(int,input().split()))

print(sum(prices[:k]))

Solution (Python):
N, K = map(int,input().split())
p = list(map(int,input().split()))

p = sorted(p)
ans = 0

for i in range(K):
    ans += p[i]

print(ans)

Solution (Python):
N, K = map(int, input().split())
p = list(map(int,input().split()))
p.sort()
print(sum(p[0:K]))

Solution (Python):
n,k= map(int , input().split())

p=list(map(int,input().split()))
p.sort()
ans =0
for i in range(k):
	ans+= p[i]
print(ans)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
print(sum(p[:k]))

Solution (Python):
N,K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
ans = 0
for i in range(K):
    ans += p[i]
print(ans)

Solution (Python):
N, K = map(int, input().split())
lst = list(map(int, input().split()))

lst.sort()
ans = sum(lst[:K])
print(ans)

Solution (Python):
n,k = a = list(map(int,input().split()))
p = list(map(int,input().split()))
ans = 0

p.sort()

for i in range(k):
    ans += p[i]

print(ans)

Solution (Python):
N,K = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]

sorted_P = sorted(P)

print(sum(sorted_P[:K]))

Solution (Python):
N,K = map(int,input().split())
p_lis = list(map(int, input().split()))

sorted_lis = sorted(p_lis)

ans = 0
for i in range(K):
    ans+=sorted_lis[i]

print(ans)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:k]))

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
print(sum(a[:k]))

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
print(sum(a[:k]))

Solution (Python):
n, k = map(int, input().split())
P = sorted(list(map(int, input().split())))

print(sum(P[0:k]))

Solution (Python):
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

n, k = inpl()
p = inpl()
p = sorted(p)
ans = 0
for i in range(n):
    ans += p[i]
    if i+1 == k:
        break
print(ans)

Solution (Python):
n, k = map(int, input().split())
p = sorted(list(map(int, input().split())))
print(sum(p[:k]))

Solution (Python):
n, k = map(int, input().split())
p = sorted(map(int, input().split()))
ans = sum(p[:k])
print(ans)

Solution (Python):
N,K=map(int,input().split())
p = list(map(int,input().split()))
ans = 0

p.sort()
for i in range(K):
  ans += p[i]
print(ans)

Solution (Python):
n,k=map(int,input().split())

p=list(map(int,input().split()))
p.sort()
total=0

for i in range(k):
  total += p[i]
print(total)

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



def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    P.sort()

    ans = 0
    for i in range(K):
        ans += P[i]
    
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n,k = map(int,input().split())
price = list(map(int,input().split()))

price.sort()

total = 0
for i in range(k):
    total += price[i]

print(total)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int, input().split()))
p_s=sorted(p)
ans=0
for i in range(k):
    ans+=p_s[i]
print(ans)

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))

p.sort()
print(sum(p[0:K]))

Solution (Python):
x = input()
arr = [int(j) for j in x.split()]
y = input()
main = [int(i) for i in y.split()]
main = sorted(main)
sum = 0
r = 0
while r < arr[1]:
  sum+=main[r]
  r+=1
print(sum)

Solution (Python):
n, k = map(int, input().split())
P = list(map(int, input().split()))
P = sorted(P)
print(sum(P[:k]))

Solution (Python):
import sys
import numpy as np
from heapq import heappush, heappop 
from bisect import bisect_left as bi_l, bisect_right as bi_r
from collections import deque, Counter, defaultdict
from itertools import combinations, product
inf = float('inf')
MOD = 10**9+7



class NumberTheory():
  def __init__(self, n=2*10**6, numpy=True):
    self.n = n
    self.np_flg = numpy 
    self.is_prime_number, self.prime_numbers = self.sieve_of_eratosthenes(n)
  
  def sieve_of_eratosthenes(self, n):
    if self.np_flg:
      sieve = np.ones(n+1, dtype=np.int64); sieve[:2] = 0
      for i in range(2, int(n**.5)+1):
        if sieve[i]: sieve[i*2::i] = 0
      prime_numbers = np.flatnonzero(sieve)
    else:
      sieve = [1] * (n+1); sieve[0] = sieve[1] = 0
      for i in range(2, int(n**.5)+1):
        if not sieve[i]: continue
        for j in range(i*2, n+1, i): sieve[j] = 0
      prime_numbers = [i for i in range(2, n+1) if sieve[i]]
    return sieve, prime_numbers 

  def prime_factorize(self, n):
    res = dict()
    if n < 2: return res
    border = int(n**.5)
    for p in self.prime_numbers:
      if p > border: break
      while n % p == 0: res[p] = res.get(p, 0)+1; n //= p
      if n == 1: return res
    res[n] = 1; return res

  def prime_factorize_factorial(self, n):
    res = dict()
    for i in range(2, n+1):
      for p, c in self.prime_factorize(i).items(): res[p] = res.get(p, 0)+c
    return res
  
  @staticmethod
  def gcd(a, b): return gcd(b, a%b) if b else abs(a)

  @staticmethod
  def lcm(a, b): return abs(a // gcd(a, b) * b)

  @staticmethod
  def find_divisors(n):
    divisors = []
    for i in range(1, int(n**.5)+1):
      if n%i: continue
      divisors.append(i)
      j = n // i
      if j != i: divisors.append(j)
    return divisors
  
  @staticmethod
  def base_convert(n, b): 
    if not n: return '0'
    res = ''
    while n:
      n, r = divmod(n, b)
      if r < 0: n += 1; r -= b
      res += str(r)
    return res[::-1]


class UnionFind():
  def __init__(self, n=10**6):
    self.root = list(range(n))
    self.height = [0] * n 
    self.size = [1] * n 
  
  def find_root(self, u):
    if self.root[u] == u: return u
    self.root[u] = self.find_root(self.root[u])
    return self.root[u]
  
  def unite(self, u, v):
    ru = self.find_root(u)
    rv = self.find_root(v)
    if ru == rv: return 
    hu = self.height[ru]
    hv = self.height[rv]
    if hu >= hv:
      self.root[rv] = ru 
      self.size[ru] += self.size[rv]
      self.height[ru] = max(hu, hv+1)
    else:
      self.root[ru] = rv 
      self.size[rv] += self.size[ru]


class Combinatorics():
  def __init__(self, N=10**9, n=10**6, mod=10**9+7, numpy=True):
    self.mod = mod
    self.nCr = dict()
    self.np_flg=numpy
    self.make_mod_tables(N, n)

  sys.setrecursionlimit(10**6)
  def choose(self, n, r, mod=None): 
    if r > n or r < 0: return 0
    if r == 0: return 1
    if (n, r) in self.nCr: return self.nCr[(n, r)]
    if not mod:
      self.nCr[(n, r)] = (self.choose(n-1, r) + self.choose(n-1, r-1))
    else:
      self.nCr[(n, r)] = (self.choose(n-1, r, mod) + self.choose(n-1, r-1, mod)) % mod
    return self.nCr[(n,r)]
  
  def cumprod(self, a):
    p = self.mod
    l = len(a); sql = int(np.sqrt(l)+1)
    a = np.resize(a, sql**2).reshape(sql, sql)
    for i in range(sql-1): a[:, i+1] *= a[:, i]; a[:, i+1] %= p
    for i in range(sql-1): a[i+1] *= a[i, -1]; a[i+1] %= p
    return np.ravel(a)[:l]

  def make_mod_tables(self, N, n):
    p = self.mod
    if self.np_flg:
      fac = np.arange(n+1); fac[0] = 1; fac = self.cumprod(fac)
      ifac = np.arange(n+1, 0, -1); ifac[0] = pow(int(fac[-1]), p-2, p)
      ifac = self.cumprod(ifac)[n::-1]
      n_choose = np.arange(N+1, N-n, -1); n_choose[0] = 1;
      n_choose[1:] = self.cumprod(n_choose[1:])*ifac[1:n+1]%p
    else:
      fac = [None]*(n+1); fac[0] = 1
      for i in range(n): fac[i+1] = fac[i]*(i+1)%p
      ifac = [None]*(n+1); ifac[n] = pow(fac[n], p-2, p)
      for i in range(n, 0, -1): ifac[i-1] = ifac[i]*i%p
      n_choose = [None] * (n+1); n_choose[0] = 1
      for i in range(n): n_choose[i+1] = n_choose[i]*(N-i)%p
      for i in range(n+1): n_choose[i] = n_choose[i]*ifac[i]%p
    self.fac, self.ifac, self.mod_n_choose = fac, ifac, n_choose


def z_algorithm(s):
  n = len(s)
  a = [0] * n; a[0] = n
  l = r = -1
  for i in range(1, n):
    if r >= i: a[i] = min(a[i-l], r-i)
    while i + a[i] < n and s[i+a[i]] == s[a[i]]: a[i] += 1
    if i+a[i] >= r: l, r = i, i+a[i]
  return a


class ABC001():
  def A():
    h1, h2 = map(int, sys.stdin.read().split())
    print(h1-h2)

  def B(): pass
  def C(): pass 
  def D(): pass 


class ABC002():
  def A():
    x, y = map(int, sys.stdin.readline().split())
    print(max(x, y))

  def B():
    vowels = set('aeiou')
    s = sys.stdin.readline().rstrip() 
    t = ''
    for c in s:
      if c in vowels: continue 
      t += c 
    print(t)

  def C():
    *coords, = map(int, sys.stdin.readline().split())
    def triangle_area(x0, y0, x1, y1, x2, y2):
      x1 -= x0; x2 -= x0; y1 -= y0; y2 -= y0;
      return abs(x1*y2 - x2*y1) / 2
    print(triangle_area(*coords))

  def D():
    n, m = map(int, sys.stdin.readline().split())
    edges = set()
    for _ in range(m):
      x, y = map(int, sys.stdin.readline().split())
      x -= 1; y -= 1
      edges.add((x, y))
    cand = []
    for i in range(1, 1<<n):
      s = [j for j in range(n) if i>>j & 1]
      for x, y in combinations(s, 2):
        if (x, y) not in edges: break
      else:
        cand.append(len(s))
    print(max(cand))


class ABC003():
  def A():
    n = int(sys.stdin.readline().rstrip())
    print((n+1)*5000)

  def B():
    atcoder = set('atcoder')
    s, t = sys.stdin.read().split()
    for i in range(len(s)):
      if s[i] == t[i]: continue
      if s[i] == '@' and t[i] in atcoder: continue 
      if t[i] == '@' and s[i] in atcoder: continue
      print('You will lose')
      return 
    print('You can win')

  def C():
    n, k, *r = map(int, sys.stdin.read().split())
    res = 0
    for x in sorted(r)[-k:]:
      res = (res+x) / 2
    print(res)

  def D(): pass 


class ABC004():
  def A():
    print(int(sys.stdin.readline().rstrip())*2)

  def B():
    c = [sys.stdin.readline().rstrip() for _ in range(4)]
    for l in c[::-1]:
      print(l[::-1])

  def C():
    n = int(sys.stdin.readline().rstrip())
    n %= 30
    res = list(range(1, 7))
    for i in range(n):
      i %= 5
      res[i], res[i+1] = res[i+1], res[i]
    print(''.join(map(str, res)))

  def D(): pass 


class ABC005():
  def A():
    x, y = map(int, sys.stdin.readline().split())
    print(y//x)

  def B():
    n, *t = map(int, sys.stdin.read().split())
    print(min(t))

  def C():
    t = int(sys.stdin.readline().rstrip())
    n = int(sys.stdin.readline().rstrip())
    a = [int(x) for x in sys.stdin.readline().split()]
    m = int(sys.stdin.readline().rstrip())
    b = [int(x) for x in sys.stdin.readline().split()]
    i = 0
    for p in b:
      if i == n: print('no'); return 
      while p-a[i] > t:
        i += 1
        if i == n: print('no'); return 
      if a[i] > p: print('no'); return 
      i += 1
    print('yes')

  def D():
    n = int(sys.stdin.readline().rstrip())
    d = np.array([sys.stdin.readline().split() for _ in range(n)], np.int64)
    s = d.cumsum(axis=0).cumsum(axis=1)
    s = np.pad(s, 1)
    max_del = np.zeros((n+1, n+1), dtype=np.int64)
    for y in range(1, n+1):
      for x in range(1, n+1):
        max_del[y, x] = np.amax(s[y:n+1, x:n+1] - s[0:n-y+1, x:n+1] - s[y:n+1, 0:n-x+1] + s[0:n-y+1, 0:n-x+1])
    res = np.arange(n**2+1)[:, None]
    i = np.arange(1, n+1)
    res = max_del[i, np.minimum(res//i, n)].max(axis=1)
    q = int(sys.stdin.readline().rstrip())
    p = np.array(sys.stdin.read().split(), dtype=np.int64)
    print(*res[p], sep='\n')


class ABC006():
  def A():
    n = sys.stdin.readline().rstrip()
    if '3' in n: print('YES')
    elif int(n)%3 == 0: print('YES')
    else: print('NO')

  def B():
    mod = 10007
    t = [0, 0, 1]
    for _ in range(1001001):
      t.append(t[-1]+t[-2]+t[-3]); t[-1] %= mod
    n = int(sys.stdin.readline().rstrip())
    print(t[n-1])
    
  def C():
    n, m = map(int, sys.stdin.readline().split())
    cnt = [0, 0, 0]
    if m == 1: cnt = [-1, -1, -1]
    else:
      if m & 1: m -= 3; cnt[1] += 1; n -= 1
      cnt[2] = m//2 - n 
      cnt[0] = n - cnt[2]
    if cnt[0]<0 or cnt[1]<0 or cnt[2]<0: print(-1, -1, -1)
    else: print(*cnt, sep=' ')
      
  def D():
    n, *c = map(int, sys.stdin.read().split())
    lis = [inf]*n 
    for x in c: lis[bi_l(lis, x)] = x 
    print(n - bi_l(lis, inf))


class ABC007():
  def A():
    n = int(sys.stdin.readline().rstrip())
    print(n-1)

  def B():
    s = sys.stdin.readline().rstrip()
    if s == 'a': print(-1)
    else: print('a')

  def C():
    r, c = map(int, sys.stdin.readline().split())
    sy, sx = map(int, sys.stdin.readline().split())
    gy, gx = map(int, sys.stdin.readline().split())
    sy -= 1; sx -=1; gy -= 1; gx -= 1
    maze = [sys.stdin.readline().rstrip() for _ in range(r)]
    queue = deque([(sy, sx)])
    dist = np.full((r, c), np.inf); dist[sy, sx] = 0
    while queue:
      y, x = queue.popleft()
      for i, j in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        i += y; j += x
        if maze[i][j] == '
        dist[i, j] = dist[y, x] + 1
        queue.append((i, j))
    print(int(dist[gy, gx]))
  
  def D(): pass 


class ABC008():
  def A():
    s, t = map(int, sys.stdin.readline().split())
    print(t-s+1)

  def B():
    n, *s = sys.stdin.read().split()
    res = defaultdict(int)
    for name in s: res[name] += 1
    print(sorted(res.items(), key=lambda x: x[1])[-1][0])

  def C():
    n, *a = map(int, sys.stdin.read().split())
    a = np.array(a)
    c = n - np.count_nonzero(a[:, None]%a, axis=1)
    print(np.sum((c+1)//2/c))
  
  def D(): pass

class ABC009():
  def A():
    n = int(sys.stdin.readline().rstrip())
    print((n+1)//2)

  def B():
    n, *a = map(int, sys.stdin.read().split())
    print(sorted(set(a))[-2])
    
  def C():
    n, k = map(int, sys.stdin.readline().split())
    s = list(sys.stdin.readline().rstrip())
    cost = [1]*n
    r = k
    for i in range(n-1):
      q = []
      for j in range(i+1, n):
        if s[j] < s[i] and cost[i]+cost[j] <= r:
          heappush(q, (s[j], cost[i]+cost[j], -j))
      if not q: continue
      _, c, j = heappop(q); j = -j 
      s[i], s[j] = s[j], s[i]
      r -= c 
      cost[i] = cost[j] = 0
    print(''.join(s))
      
  def D(): pass 


class ABC010():
  def A():
    print(sys.stdin.readline().rstrip()+'pp')
  def B():
    n, *a = map(int, sys.stdin.read().split())
    tot = 0
    for x in a:
      c = 0 
      while x%2==0 or x%3==2:
        x -= 1
        c += 1
      tot += c
    print(tot)

  def C():
    sx, sy, gx, gy, t, v, n, *xy = map(int, sys.stdin.read().split())
    x, y = np.array(xy).reshape(-1, 2).T
    def dist(x1, y1, x2, y2):
      return np.sqrt((x2-x1)**2 + (y2-y1)**2)
    ans = 'YES' if (dist(sx, sy, x, y)+dist(x, y, gx, gy) <= v*t).any() else 'NO'
    print(ans)

  def D(): pass 

class ABC011():
  def A():
    n = int(sys.stdin.readline().rstrip())
    print(n%12+1)

  def B():
    s = sys.stdin.readline().rstrip() 
    print(s[0].upper()+s[1:].lower())

  def C():
    n, *ng = map(int, sys.stdin.read().split())
    ng = set(ng)
    if n in ng: print('NO')
    else:
      r = 100
      while n > 0:
        if r == 0: print('NO'); return
        for i in range(3, 0, -1):
          if (n-i) in ng: continue 
          n -= i
          r -= 1
          break 
        else: print('NO'); return 
      print('YES')

  def D(): pass 


class ABC170():
  def A():
    x = [int(x) for x in sys.stdin.readline().split()]
    for i in range(5):
      if x[i] != i+1:
        print(i+1)
        break

  def B():
    x, y = map(int, sys.stdin.readline().split())
    print('Yes' if 2*x <= y <= 4*x and y%2 == 0 else 'No')
      
  def C():
    x, n, *p = map(int, sys.stdin.read().split())
    a = list(set(range(102)) - set(p))
    a = [(abs(y-x), y) for y in a]
    print(sorted(a)[0][1])

  def D():
    n, *a = map(int, sys.stdin.read().split())
    cand = set(a)
    cnt = 0
    for x, c in sorted(Counter(a).items()):
      cnt += c == 1 and x in cand
      cand -= set(range(x*2, 10**6+1, x))
    print(cnt)

  def E():
    n, q = map(int, sys.stdin.readline().split())
    queue = [] 
    num_kindergarten = 2*10**5
    queue_kindergarten = [[] for _ in range(num_kindergarten)]
    highest_kindergarten = [None] * num_kindergarten
    where = [None] * n
    rate = [None] * n

    def entry(i, k):
      where[i] = k
      while queue_kindergarten[k]:
        r, j = heappop(queue_kindergarten[k])
        if where[j] != k or j == i: continue 
        if rate[i] >= -r:
          highest_kindergarten[k] = rate[i]
          heappush(queue, (rate[i], k, i))
        heappush(queue_kindergarten[k], (r, j))
        break
      else:
        highest_kindergarten[k] = rate[i]
        heappush(queue, (rate[i], k, i))
      heappush(queue_kindergarten[k], (-rate[i], i))

    def transfer(i, k):
      now = where[i]
      while queue_kindergarten[now]:
        r, j = heappop(queue_kindergarten[now])
        if where[j] != now or j == i: continue
        if highest_kindergarten[now] != -r:
          highest_kindergarten[now] = -r
          heappush(queue, (-r, now, j))
        heappush(queue_kindergarten[now], (r, j))
        break
      else:
        highest_kindergarten[now] = None
      entry(i, k)

    def inquire():
      while True:
        r, k, i = heappop(queue)
        if where[i] != k or r != highest_kindergarten[k]: continue 
        heappush(queue, (r, k, i))
        return r

    for i in range(n):
      a, b = map(int, sys.stdin.readline().split())
      rate[i] = a 
      entry(i, b-1)
    for _ in range(q):
      c, d = map(int, sys.stdin.readline().split())
      transfer(c-1, d-1)
      print(inquire())
    
  def F(): pass 


class ABC171():
  def A():
    c = sys.stdin.readline().rstrip()
    print('a' if c < 'A' else 'A')
  def B():
    n, k, *p = map(int, sys.stdin.read().split())
    print(sum(sorted(p)[:k]))
  def C(): pass 
  def D(): pass 
  def E(): pass 
  def F(): pass 

if __name__ == '__main__':
  ABC171.B()

Solution (Python):
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
print(sum(a[:k]))

Solution (Python):
n, k = map(int, input().split())
print(sum(sorted(list(map(int, input().split())))[:k]))

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))

p.sort()
print(sum(p[:k]))

Solution (Python):

N, K = map(int,(input().split()))
ps = list(map(int,(input().split())))
ps.sort()


print(sum(ps[:K]))

Solution (Python):
N,K = map(int,input().split())
p = list(map(int,input().split()))

ans = 0
for i in range(K):
    ans += min(p)
    p.remove(min(p))

print(ans)

Solution (Python):
N, K=list(map(int,input().split()))
P=list(map(int,input().split()))
P.sort()
print(sum(P[0:K]))

Solution (Python):
N, K = map(int, input().split())
P = sorted([int(i) for i in input().split()])
print(sum(P[:K]))

Solution (Python):
n, k = map(int, input().split())
prices = list(map(int, input().split()))

prices.sort()
purchasing_price = sum(prices[0:k])

print(purchasing_price)

Solution (Python):
n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
cnt = 0
s = 0
while(cnt < k):
    s = s+l[cnt]
    cnt = cnt+1

print(s)

Solution (Python):
n, k = map(int, input().split())
p = list(sorted(map(int, input().split())))
print(sum(p[:k]))

Solution (Python):
def b171(n, k, plist):

    plist.sort()

    return sum(plist[:k])

def main():
    n, k = map(int, input().split())
    plist = list(map(int, input().split()))
    print(b171(n, k, plist))

if __name__ == '__main__':
    main()

Solution (Python):
n,k = map(int, input().split())
p = sorted(list(map(int, input().split())))
ans = 0
for i in range(k):
    ans += p[i]
print(ans)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:k]))

Solution (Python):
n, k = map(int,input().split())
data = sorted([int(i) for i in input().split()], reverse = False)
ans = 0

ans = sum(data[:k])
print(ans)

Solution (Python):
N , K =list(map(int,input().split()))
p=list(map(int,input().split()))
p.sort()
ans = 0
for i in range(K):
    ans += p[i]
print( ans )

Solution (Python):
NK = input()
num = NK.split()
N = num[0]
K = num[1]

P = input()
Pn = P.split()


Pn_a = [int(i) for i in Pn]
Pn_b = sorted(Pn_a)

price = 0

for i in range(int(K)):
    price += int(Pn_b[i])
    
print(price)

Solution (Python):
N,K = map(int, input().split())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(0,K):
  ans += l[i]
print(ans)

Solution (Python):
N, K = map(int, input().split())
fruits = map(int, input().split())

print(sum(sorted(fruits)[:K]))

Solution (Python):
N, K = map(int, input().split())
print(sum(sorted(list(map(int, input().split())))[0:K]))

Solution (Python):
n,m=[int(i) for i in  input().split()]
a=[int(i) for i in input().split()]
count=0
sum=0
while(count<m):
    count=count+1
    sum=sum+(min(a))
    a.remove(min(a))
print(sum)

Solution (Python):
n, k = map(int, input().split())
final = 0
x = sorted(list(map(int, input().split())))
for i in range(0, k):
    final += x[i]

print(final)

Solution (Python):
n,k=map(int,input().split())
P=list(map(int,input().split()))
P.sort()
print(sum(P[:k]))

Solution (Python):
N, K = map(int, input().split())
p = sorted(map(int, input().split()))

print(sum(p[:K]))

Solution (Python):
N, K = map(int,input().split())
P = list(map(int,input().split()))
P_sorted = sorted(P)
sum_ = 0
i = 0
while K>0:
    sum_ = sum_+P_sorted[i]
    K=K-1
    i = i+1
print(sum_)