Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split())

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

D=[]
for i in range(M):
    B, C = map(int, input().split())
    D += [C]*B

D.sort(reverse = True)
A += D[:N]
A.sort(reverse = True)

print(sum(E[:N])) 

### FIXED CODE ###

N, M = map(int, input().split())

A = sorted(list(map(int, input().split())), reverse=True)

B = []
for i in range(M):
    b, c = map(int, input().split())
    B.append([b, c])

B.sort(key=lambda x:(-x[1]))

cnt = 0
ans = 0
a = 0
b = 0
while True:
    if b <= M-1 and A[a] <= B[b][1]:
        n = min(B[b][0], N-cnt)
        ans += B[b][1]*n
        cnt += n
        if cnt == N:
            print(ans)
            break
        b += 1
    elif a <= N-1:
        cnt += 1
        ans += A[a]
        if cnt == N:
            print(ans)
            break
        a += 1
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
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 LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N = I()
s = S()

inf = 10**9+7

from math import factorial
def c(n, r):
    a = factorial(n) / factorial(r) / factorial(n - r)
    return a

result = 0
counts = collections.Counter(s)
red = [i for i in counts.values()]
tmp = 1
for i in red:
    tmp *= i
#  print('tmp', tmp)
for i in range(1, len(s)+1):
    #  print(i)
    #  import pdb
    #  pdb.set_trace()
    #  combis = list(itertools.combinations(counts, i))
    #  print('combis' ,combis)
    result += c(len(s), i)
    #  for combi in combis:
    #      #  print('combi', combi)
    #      tmp = 1
    #      for c in combi:
    #          #  print('c', c)
    #          tmp *= counts[c]
    #      #  print('tmp', tmp)
    #      result += tmp
for i in range(1, tmp):
    result -= c(tmp, i)
print(int(result)%inf)


### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
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 LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N = I()
s = S()

inf = 10**9+7

counts = collections.Counter(s)
result = 1
for i in counts.values():
    result *= i+1
result -= 1
print(result%inf)
exit()
M,N = map(eval,input().split())
user = list(eval(input().replace(" ",",")))
sum = 0
for i in user:
    sum = sum + int(i)
result = M - sum
if result < 0:
    print("-1")
else:
    print(int(result))

### FIXED CODE ###

N,M = (input()).split()
task = input().split()
list1 = []
sum = 0
for i in task:
    list1.append(i)
for j in list1:
    sum = sum + int(j)
result = int(N) - sum
if result < 0:
    print(-1)
else:
    print(result)
BLOCK_WIDTH = 4
BLOCK_HEIGHT = 2
field = []
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
w = 0
h = 0
xg = 0
yg = 0

def main():
    global field, w, h, xg, yg
    while True:
        w, h = map(int, input().split())
        if w == 0 and h == 0:
            break
        xs, ys = map(int, input().split())
        xg, yg = map(int, input().split())
        n = int(input())
        field = [[0] * w for _ in range(h)]
        for i in range(n):
            c, d, x, y = map(int, input().split())
            arrangement(c, d, x, y)

        if dfs(field[ys][xs], xs, ys):
            print("OK")
        else:
            print("NG")


def arrangement(c, d, x, y):
    global field
    if d == 0:
        for i in range(BLOCK_HEIGHT):
            for j in range(BLOCK_WIDTH):
                field[y + i][x + j] = c
    else:
        for i in range(BLOCK_WIDTH):
            for j in range(BLOCK_HEIGHT):
                field[y + i][x + j] = c


def dfs(c, x, y):
    global field

    if x < 0 or x >= w or y < 0 or y >= h:
        return False
    if field[y][x] != c:
        return False
    if x == xg and y == yg:
        return True
    field[y][x] = -1
    for i in range(4):
        next_x = x + dx[i]
        next_y = y + dy[i]
        if dfs(c, next_x, next_y):
            return True

    return False


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

BLOCK_WIDTH = 4
BLOCK_HEIGHT = 2
field = []
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
w = 0
h = 0
xg = 0
yg = 0
start_color = 0

def main():
    global field, w, h, c, xg, yg, start_color
    while True:
        w, h = map(int, input().split())
        if w == 0 and h == 0:
            break
        xs, ys = map(int, input().split())
        xg, yg = map(int, input().split())
        xs -= 1
        ys -= 1
        xg -= 1
        yg -= 1
        n = int(input())
        field = [[0] * w for _ in range(h)]
        for i in range(n):
            c, d, x, y = map(int, input().split())
            arrangement(c, d, x - 1, y - 1)

        start_color = field[ys][xs]
        if dfs(xs, ys):
            print("OK")
        else:
            print("NG")


def arrangement(c, d, x, y):
    if d == 0:
        [[draw(x + j, y + i, c) for j in range(BLOCK_WIDTH)] for i in range(BLOCK_HEIGHT)]
    else:
        [[draw(x + j, y + i, c) for j in range(BLOCK_HEIGHT)] for i in range(BLOCK_WIDTH)]


def draw(x, y, c):
    global field
    field[y][x] = c


def dfs(x, y):
    global field

    if x == xg and y == yg:
        return True
    if start_color == 0:
        return False
    field[y][x] = 0
    for i in range(4):
        next_x = x + dx[i]
        next_y = y + dy[i]
        if next_x < 0 or next_x >= w or next_y < 0 or next_y >= h:
            continue
        if field[next_y][next_x] != start_color:
            continue
        if dfs(next_x, next_y):
            return True

    return False


if __name__ == '__main__':
    main()
IINF = 10 ** 18


def main():
    N, M = list(map(int, input().split()))
    X = list(map(int, input().split()))
    X = sorted(X)
    left = -IINF
    right = IINF

    for i in range(N):
        if len(X) == 0:
            break
        elif i == 0:
            left = X[0]
            X.pop(0)
        elif i == 1:
            right = X[-1]
            X.pop(len(X)-1)
        else:
            if abs(X[1] - X[-1]) < abs(X[-2] - X[0]):
                left = X[0]
                X.pop(0)
            else:
                right = X[-1]
                X.pop(-1)

    ans = 0
    while len(X) > 0:
        # print(ans, X)
        if abs(left - X[0]) < abs(right - X[-1]):
            ans += abs(left - X[0])
            left = X[0]
            X.pop(0)
        else:
            ans += abs(right - X[-1])
            right = X[-1]
            X.pop(len(X)-1)
        # b = min(abs(left - X[0]), abs(right - X[-1]))
        # print(b, X)
        # print(abs(X[0] - X[-1]) + b)
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

IINF = 10 ** 18


def main():
    N, M = list(map(int, input().split()))
    X = list(map(int, input().split()))
    X = sorted(X)
    # left = -IINF
    # right = IINF

    # print(M, N)
    if M <= N:
        print(0)
        return
    else:
        L = []
        for i in range(M-1):
            L.append(X[i+1]-X[i])

        # print(L)

        L.sort()
        if N == 1:
            ans = sum(L)
            print(ans)
        else:
            ans = sum(L[0:-(N-1)])
            print(ans)

    # for i in range(N):
    #     if len(X) == 0:
    #         break
    #     elif i == 0:
    #         left = X[0]
    #         X.pop(0)
    #     elif i == 1:
    #         right = X[-1]
    #         X.pop(len(X)-1)
    #     else:
    #         if abs(X[1] - X[-1]) < abs(X[-2] - X[0]):
    #             left = X[0]
    #             X.pop(0)
    #         else:
    #             right = X[-1]
    #             X.pop(-1)

    # ans = 0
    # while len(X) > 0:
    #     # print(ans, X)
    #     if abs(left - X[0]) < abs(right - X[-1]):
    #         ans += abs(left - X[0])
    #         left = X[0]
    #         X.pop(0)
    #     else:
    #         ans += abs(right - X[-1])
    #         right = X[-1]
    #         X.pop(len(X)-1)
    #     # b = min(abs(left - X[0]), abs(right - X[-1]))
    #     # print(b, X)
    #     # print(abs(X[0] - X[-1]) + b)
    # print(ans)


if __name__ == '__main__':
    main()
import sys
import math
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    K = int(input())
    S = input().strip()

    MOD = 10 ** 9 + 7

    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]

    def cmb(n, k, p):
        if (k < 0) or (n < k):
            return 0
        r = min(k, n - k)
        return fact[n] * factinv[k] * factinv[n - k] % p

    N = 10 ** 6 + 5000
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)

    ans = 0
    for i in range(K + 1):
        if len(S) == 1:
            ans += pow(25, i, MOD) * pow(26, K - i, MOD)
        else:
            ans += pow(25, i, MOD) * cmb(i + len(S) - 1, len(S) - 1, MOD) * pow(26, K - i, MOD)

    print(ans % MOD)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import math
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    K = int(input())
    S = input().strip()

    MOD = 10 ** 9 + 7

    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]

    def cmb(n, k, p):
        if (k < 0) or (n < k):
            return 0
        r = min(k, n - k)
        return fact[n] * factinv[k] * factinv[n - k] % p

    N = 10 ** 6 * 2
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)

    ans = 0
    for i in range(K + 1):
        if len(S) == 1:
            ans += pow(25, i, MOD) * pow(26, K - i, MOD)
        else:
            ans += pow(25, i, MOD) * cmb(i + len(S) - 1, len(S) - 1, MOD) * pow(26, K - i, MOD)

    print(ans % MOD)


if __name__ == '__main__':
    main()
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()] 
if a[0]!=0||a[n]==0:
    print (0%998244353)
else:
    a = Counter(a)
    ans = 1
    for i in range(1,len(a)-1): 
        ans*=a[i]**a[i+1]
    print(ans%998244353)


### FIXED CODE ###

import collections
n = int(input())
d = list(map(int, input().split()))
mod = 998244353
f = collections.Counter(d)
# print(f)
if d[0] != 0 or f[0] != 1:  # 0は一個だけ
    print(0)
    exit()
ans = 1
box = 1  # 値自体の個数を保存
maxd = max(d)

for i in range(maxd+1):
    ans = ans*box**f[i]
    ans %= mod
    box = f[i]
print(ans)
import sys
import math
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    D = list(map(int, input().split()))
    count = Counter(D[1:])
    if D[0] != 0:
        # 頂点1に対しては、0以外有り得ない
        print(0)
        return
    results = [0, count[1]]
    for d in sorted(count.keys())[1:]:
        results.append(results[d - 1] * math.factorial(count[d]))
    print(sum(results[2:]) % 998244353)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    D = list(map(int, input().split()))
    count = Counter(D)
    result = 1
    if D[0] != 0 or count[0] != 1:
        print(0)
        return
    for i in range(max(D)):
        result *= count[i] ** count[i + 1]
    print(result % 998244353)


if __name__ == "__main__":
    main()
s = input()
k = int(input())
sl = []
if len(s) > 1:
    for i in range(len(s)-1):
        for j in range(i, len(s)+1):
            if abs(i-j) <= 5 and i != j:
                s_part = s[i:j]
                if s_part not in set(sl):
                    sl.append(s_part)
    sll = sorted(sl)
    print(sll[k-1])
else:
    print(s)

### FIXED CODE ###

s = input()
l = int(input())
char = []
if len(s) == 1:
    print(s)
else:
    for i in range(len(s)):
        char.append(s[i])
    charset = set(char)
    ans = []
    for i in charset:
        for j in range(len(s)):
            if i == s[j]:
                for k in range(1, 6):
                    ans.append(s[j:j+k])
    ansset = sorted(list(set(ans)))
    print(ansset[l-1])
from math import factorial

X, Y = map(int, input().split())
mod = 10 ** 9 + 7
if (X + Y) % 3 != 0:
    print(0)
else:
    n = (2 * Y - X) // 3
    m = (2 * X - Y) // 3
    print((factorial(n+m)%mod * pow(factorial(n)*factorial(m), mod-2, mod))%mod)

### FIXED CODE ###

X, Y = map(int, input().split())
mod = 10 ** 9 + 7
if (X + Y) % 3 != 0:
    print(0)
    exit()
    
n = (2 * Y - X) // 3
m = (2 * X - Y) // 3
if n < 0 or m < 0:
    print(0)
    exit()    

ans = 1
for i in range(1, n+1):
    ans *= (n+m+1-i) * pow(i, mod-2, mod)
    ans %= mod
    
print(ans)
n = int(input())
ans = 0
for i in range(n+1):
  if not (i % 3 == 0 or i % 5 == 0):
	ans += i
   
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(n+1):
  if not (i % 3 == 0 or i % 5 == 0):
    ans += i
print(ans)
p = [[0 for i in xrange(16)] for j in xrange(16)]
while 1:
    a,b = map(int, raw_input().split())
    if a==b==0: break
    n = input()
    for i in xrange(b):
        for j in xrange(a):
            p[i][j] = 0
    for i in xrange(n):
        x,y = map(int, raw_input().split())
        p[y-1][x-1] = -10**6
    p[0][0] = 1
    for i in xrange(b):
        for j in xrange(a):
            if p[i][j]<0: continue
            p[i+1][j] += p[i][j]; p[i][j+1] += p[i][j];
    print p[b-1][a-1]

### FIXED CODE ###

p = [[0 for i in xrange(17)] for j in xrange(17)]
while 1:
    a,b = map(int, raw_input().split())
    if a==b==0: break
    n = input()
    for i in xrange(b):
        for j in xrange(a):
            p[i][j] = 0
    for i in xrange(n):
        x,y = map(int, raw_input().split())
        p[y-1][x-1] = -10**6
    p[0][0] = 1
    for i in xrange(b):
        for j in xrange(a):
            if p[i][j]<0: continue
            p[i+1][j] += p[i][j]; p[i][j+1] += p[i][j];
    print p[b-1][a-1]
s = input()
t = input()

idx = -1
if set(t) <= set(s):
    for i in t:
        idx = s.find(i, idx+1)
        s += s
    print(idx+1)
else:
    print(-1)


### FIXED CODE ###

s = input()
t = input()

idx = -1
count = 0

if set(t) <= set(s):
    for i in t:
        idx = s.find(i, idx+1)
        if idx == -1:
            idx = s.find(i)
            count += 1
    pdc = count * len(s)
    total_idx = (idx + 1) + pdc 
    print(total_idx)
else:
    print(-1)
dataset = [[input().split() for _ in range(8)] for _ in range(3)]
tmp = []
for i in range(3):
    s = sorted(dataset[i], key=lambda x: x[1])[:3]
    tmp.append(s[-1])
    for p in s[:2]:
        print(*p)
a, b = sorted(tmp, key=lambda x: x[1])[:2]
print(*a, "\n", *b)

### FIXED CODE ###

pts = [[input().split() for _ in range(8)] for _ in range(3)]
npts = [sorted(pts[i], key=lambda x: float(x[1]))[:4] for i in range(3)]
ts = [sorted((npts[i][j] for i in range(3) for j in range(2, 4)), key=lambda x: float(x[1]))[:2]]
gen = (print(*npts[i][j]) for i in range(3) for j in range(2))
ans = lambda *x: print(*ts[0][0])
ans(*gen)
print(*ts[0][1])
def gcd(a,b):
	x,y = min(a,b), max(a,b)
	while x*y>0:
		x,y = y-x,x
	return y

N,M=map(int,input().split())
S=input()
T=input()
g=gcd(N,M)
p,q=M//g,N//g
print(N*M//g) if S[0::q]==T[0::p] else print('-1')

### FIXED CODE ###

def gcd(a,b):
	x,y = min(a,b), max(a,b)
	while x*y>0:
		x,y = min(x,y), max(x,y)
		x,y = y-x,x
	return y

N,M=map(int,input().split())
S=input()
T=input()
g=gcd(N,M)
p,q=M//g,N//g
print((N//g)*M) if S[0::q]==T[0::p] else print('-1')
w=str(input())
if w==RRR:
    print(3)
elif w==SRR:
    print(2)
elif w==RRS:
    print(2)
elif w==RSR:
    print(1)
elif w==RSS:
    print(1)
elif w==SRS:
    print(1)
elif w==SSR:
    print(1)
else :
    print(0)

### FIXED CODE ###

w=input()
if w=="RRR":
    print(3)
elif w=="SRR":
    print(2)
elif w=="RRS":
    print(2)
elif w=="RSR":
    print(1)
elif w=="RSS":
    print(1)
elif w=="SRS":
    print(1)
elif w=="SSR":
    print(1)
else :
    print(0)
a, b, c, d = map(int, input().split())
if a+b > c+d:
    pirnt('Left')
elif a+b == c+d :
    print('Balanced')
elif a+b < c+d :
    print('Right')

### FIXED CODE ###

a, b, c, d = map(int, input().split())
if (a+b) > (c+d):
    print('Left')
elif (a+b) == (c+d) :
    print('Balanced')
else :
    print('Right')
import numpy as np
N = int(input())
T,A = map(int,input().split(" "))
H =  list(map(int,input().split(" ")))
H = list(map(lambda x: abs((T - x*0.006)-A),H))

print(np.argmin(H)+1)


### FIXED CODE ###

import numpy as np
N = int(input())
T,A = map(int,input().split(" "))
H =  list(map(int,input().split(" ")))
H = list(map(lambda x: abs((T - x*0.006)-A),H))

print(np.argmin(H)+1)
n = int(input())
l = [input() for i in range(n)]

mylist = []
for s in l:
    s_list = [ c for c in s]
    mylist.append("".join(sorted(s_list)))

ans=0
for i in range(len(mylist)):
    print(mylist)
    ans += mylist.count(mylist[0]) - 1
    del mylist[0]

print(ans)

### FIXED CODE ###

n = int(input())
i = 0
sortedSet = {}
while i < n:
    temp = ''.join(sorted(input()))

    if temp in sortedSet:
        sortedSet[temp]+=1
    else:
        sortedSet[temp]=1
    i += 1

result = 0
for v in sortedSet.values():
    result = int(result + v*(v-1)/2)

print(result)
n = int(input())
s = input()
count1 = 0
count2 = 0
m = -1
t = n
for x in range(n):
	if s[x] == "#":
		m = x
		break
if m != -1:
	for u in range(m,n):
	    if s[u] == ".":
		    count1 += 1
		else:
			count2 += 1
	while s[t] == "#":
		count2 -= 1
		t = t-1
print(min(count1,count2))

### FIXED CODE ###

n = int(input())
s = input()
counter = s.count(".")
ans = counter
for i in range(n):
	if s[i] == ".":
		counter -= 1
	else:
		counter += 1
	ans = min(ans, counter)
print(ans)
dp=[[0 for j in range(10)] for i in range(10)]
#print(dp)
h,w=map(int,input().split())
for i in range(10):
    s=list(map(int,input().split()))
    for j in range(10):
        dp[i][j]=s[j]

#print(dp)

for k in range(10):
    for i in range(10):
        for j in range(10):
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])
#print(dp)
c=0
for i in range(h):
    s=list(map(int,input().split()))
    for j in range(w):
        if s[j]==-1 or s[j]==1:
            continue
        else:
            c+=dp[s[j]][i]
            #print(s[j])
            #print(c)

#print(dp)
print(c)


### FIXED CODE ###

dp=[[0 for j in range(10)] for i in range(10)]

h,w=map(int,input().split())
for i in range(10):
    s=list(map(int,input().split()))
    for j in range(10):
        dp[i][j]=s[j]

for k in range(10):
    for i in range(10):
        for j in range(10):
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])
c=0
for i in range(h):
    s=list(map(int,input().split()))
    for j in range(w):
        if s[j]!=-1 and s[j]!=1:
            c+=dp[s[j]][1]
print(c)
s=str(input())
k=int(input())

res=''

if len(s)>=k:
	for i in range(k):
		if s[i]!=1:
			res=s[i]			
			break
		if i==k-1:
			res='1'
else:
	for i in range(len(s)):
		if s[i]!='1':
			res=s[i]
			break

print(res)

### FIXED CODE ###

r,c=map(int,input().split())
res=(r-1)*(c-1)
print(res)
N = int(input())
S = input()
S = list(S)
count = 0
for i in range(len(S)):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                count = count+1
print(count)

### FIXED CODE ###

N = int(input())
S = input()
S = list(S)
count = 0
for i in range(N-2):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                count+=1
print(count)
A, B, K = map(int, input().split())
quant = A + B

if quant - K <= 0:
    print('0 0')
else:
    RNT = A - K  # RemainNumTime
    a = max(RNT, 0)
    b = min(B + RNT, B)
    print(a + ' ' + b)

### FIXED CODE ###

A, B, K = map(int, input().split())
quant = A + B

if quant - K <= 0:
    print('0 0')
else:
    rnt = A - K  # RemainNumTime
    a = max(rnt, 0)
    b = min(B + rnt, B)
    print(str(a) + ' ' + str(b))
x=int(input())
print(x//3600,x%3600//60,x%60,sep=':')


### FIXED CODE ###

x=int(input())
print(x//3600,x%3600//60,x%60,sep=':')
N = int(input())
numbers = [x for x in map(int, input().split())]
count = 0
on = True
while on:
  val = [x % 2 == 0 for x in numbers]
  if False in val:
    print(count)
    break
  else:
    numbers = [x//2 for x in numbers]
    count += 1

### FIXED CODE ###

print(input().count('1'))
N, M = map(int, raw_input().split())
E = [[] for _ in range(N)]
for _ in range(M):
  a, b = map(int, raw_input().split())
  E[a-1] += [b-1]
  E[b-1] += [a-1]

ok = True
for e in E:
  if len(e)%2!=0:
    ok = False
if not ok:
  print "No"
  exit(0)

ok = False
for e in E:
  if len(e)>=6:
    ok = True
if ok:
  print "Yes"
  exit(0)

c = 0
for e in E:
  if len(e)==4:
    c += 1
if c>=3:
  print "Yes"
  exit(0)
if c<=1:
  print "No"
  exit(0)

for i in range(len(E)):
  if len(E[i])==4:
    c = 0
    for v in E[i]:
      p = i
      while len(v)==2:
        if E[v][0]==p:
          p = v
          v = E[v][1]
        else:
          p = v
          v = E[v][0]
      if v==i:
        c += 1
    if c==2:
      print "Yes"
      exit(0)
    else:
      print "No"
      exit(0)


### FIXED CODE ###

N, M = map(int, raw_input().split())
E = [[] for _ in range(N)]
for _ in range(M):
  a, b = map(int, raw_input().split())
  E[a-1] += [b-1]
  E[b-1] += [a-1]

ok = True
for e in E:
  if len(e)%2!=0:
    ok = False
if not ok:
  print "No"
  exit(0)

ok = False
for e in E:
  if len(e)>=6:
    ok = True
if ok:
  print "Yes"
  exit(0)

c = 0
for e in E:
  if len(e)==4:
    c += 1
if c>=3:
  print "Yes"
  exit(0)
if c<=1:
  print "No"
  exit(0)

for i in range(len(E)):
  if len(E[i])==4:
    c = 0
    for v in E[i]:
      p = i
      while len(E[v])==2:
        if E[v][0]==p:
          p = v
          v = E[v][1]
        else:
          p = v
          v = E[v][0]
      if v==i:
        c += 1
    if c==2:
      print "Yes"
      exit(0)
    else:
      print "No"
      exit(0)
def f(y):

    if 0 <= y <=999:
        print(1000-y)
    else:
        b = int(y / 100)
        c = int(str(b)[1])
        g = 9-c
        h = int(y/10)
        i = int(str(h)[2])

        if y %1000==0:
            print("0")
        elif y % 500==0 and x % 1000!=0:
            print("500")
        elif y % 100==0 and x % 500!=0:
            f = 10-c
            print(f*100)
        elif y % 10 ==0 and x % 100!=0:
            j =10-i
            print(g*100+j*10)
        elif y % 10!=0:
            k = int(str(y)[3])
            l = 9 - i
            m = 10-k
            print(g*100+l*10+m)


y = input("number")

x = f(int(y))






### FIXED CODE ###


def f(y):

    if 1 <= y <=999:
        print(1000-y)
    elif 1000<= y <= 10000 :
        b = int(y / 100)
        c = int(str(b)[1])
        g = 9-c
        h = int(y/10)
        i = int(str(h)[2])

        if y %1000==0:
            print("0")
        elif y % 500==0 and y % 1000!=0:
            print("500")
        elif y % 100==0 and y % 500!=0:
            f = 10-c
            print(f*100)
        elif y % 10 ==0 and y % 100!=0:
            j =10-i
            print(g*100+j*10)
        elif y % 10!=0:
            k = int(str(y)[3])
            l = 9 - i
            m = 10-k
            print(g*100+l*10+m)


y = input()
x = f(int(y))
# -*- coding: utf-8 -*-

N = int(input())
H = list(map(int, input().split()))

max = 0
ans = "Yes"
for i in range(N-1):
    if max - H[i] > 1:
        ans = "No"
        break
    max = max(max, H[i])
    
print(ans)



### FIXED CODE ###

# -*- coding: utf-8 -*-

A, B, C = map(int, input().split())

print(max(C-(A-B), 0))