Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n,q = map(int,input().split())
S = input()
for i in range(q):
    l,r = map(int,input().split())
    A = S[:l].count('AC')
    B = S[:r].count('AC')
    print(B-A)


### FIXED CODE ###

n,q = map(int,input().split())
S = input()
N = [0]*(10**5+1)
for i in range(1,n):
    if S[i-1]=='A'and S[i]=='C':
        N[i] = 1
SUM = [0]*(10**5+1)
for i in range(1,n):
    SUM[i] += SUM[i-1]+N[i]
for i in range(q):
    l,r = map(int,input().split())
    print(SUM[r-1]-SUM[l-1])
### BUGGY CODE ###

def sol():
    _, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))

    AF = [(a, f) for a, f in zip(sorted(A), sorted(F, reverse=True))]

    def isOk(T):
        ret = 0
        for a, f in AF:
            m = T // f
            if a > m:
                ret += a - T // f
        return ret <= K

    ok = max(a * f for a, f in AF)
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if isOk(mid):
            ok = mid
        else:
            ng = mid

    print(ok)

sol()


### FIXED CODE ###

import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    _, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))

    A.sort()
    F.sort(reverse=True)

    def isOk(t):
        cnt = 0
        for a, f in zip(A, F):
            ness = t // f
            if a <= ness:
                continue
            cnt += a - ness

        if cnt > K:
            return False
        else:
            return True

    ng = -1
    ok = max(A) * max(F) + 10

    while ok - ng > 1:
        mid = (ok + ng) // 2
        if isOk(mid):
            ok = mid
        else:
            ng = mid
    print(ok)


sol()
### BUGGY CODE ###

H,N = [int(zz) for zz in input().split()]
mahou = [[int(zz) for zz in input().split()] for _ in range(N)]

dmg = [i[0] for i in mahou]
mp = [i[1] for i in mahou]

dp = [[0]*(H+1) for _ in range(N)]
for j in range(1,H+1):
    if j <= dmg[0]:
        dp[0][j] = mp[0]
    else:
        dp[0][j] = dp[0][j-dmg[0]]+mp[0]

for i in range(1,N):
    for j in range(1,H+1):
        if j <= dmg[i]:
            dp[i][j] = min(mp[i],dp[i-1][j])
        else:
            dp[i][j] = min(dp[i][j-dmg[i]]+mp[i],dp[i-1][j])

print(dp[-1][-1])


### FIXED CODE ###

H,N = [int(zz) for zz in input().split()]
li = [[int(zz) for zz in input().split()] for _ in range(N)]

dp = [[0]*(H+1) for _ in range(N)]

for j in range(1,H+1):
    if j <= li[0][0]:
        dp[0][j] = li[0][1]
    else:
        dp[0][j] = dp[0][j-li[0][0]]+li[0][1]

for i in range(1,N):
    for j in range(1,H+1):
        if j <= li[i][0]:
            dp[i][j] = min(li[i][1],dp[i-1][j])
        else:
            dp[i][j] = min(dp[i][j-li[i][0]]+li[i][1],dp[i-1][j])

print(dp[-1][-1])
### BUGGY CODE ###

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

A.append(0)

for j in range(K):
    B = [0] * (N+1)
    for i in range(N):
        B[max(i - A[i],0)] += 1
        B[min(i + A[i] + 1,N)] -= 1
    A = [0] * (N+1)
    a = 0
    for i in range(N):
        a += B[i]
        A[i] = a

print(*A[:-1])

### FIXED CODE ###

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

A.append(0)

for j in range(min(50,K)):
    B = [0] * (N+1)
    for i in range(N):
        B[max(i - A[i],0)] += 1
        B[min(i + A[i] + 1,N)] -= 1
    A = [0] * (N+1)
    a = 0
    for i in range(N):
        a += B[i]
        A[i] = a

print(*A[:-1])
### BUGGY CODE ###

n = int(input())
L1 = list(map(int,input().split()))
m = int(input())
L2 = list(map(int,input().split()))
flag = False
cnt = 0
for i in range(m):
    if L2.count(L2[i]) <= L1.count(L2[i]):
        flag = True
        cnt +=1
    else:
        flag = False
if flag and cnt == len(L2):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

from collections import Counter
n = int(input())
L1 = list(map(int,input().split()))
m = int(input())
L2 = list(map(int,input().split()))
li1 = Counter(L1)
li2 = Counter(L2)

flag = False
for i in range(m):
    if li1[L2[i]] >= li2[L2[i]]:
        flag = True
    else:
        flag = False
        break
if flag:
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

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

answer1=1
answer2=0
for i in range(n):
  answer1=answer1*a[i]
  answer2=answer2*a[i]
  if answer1>=10**18:
    answer2=answer2+(answer1//(10**18))
    answer1=answer1%(10**18)
    
if answer2>=1 and answer1!=0:
  print(-1)
else:
  print(answer2*(10**18)+answer1)

### FIXED CODE ###

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

b1=1
b2=0
b3=0

if 0 in a:
  print(0)
else:
  for i in range(n):
    b1*=a[i]
    b2*=a[i]
    if b1>=10**9:
      b2+=b1//(10**9)
      b1%=10**9
    if b2>=10**9:
      b3+=b2//(10**9)
      b2%=10**9
      break
  
  if b3>=1 and (b1!=0 or b2!=0):
    print(-1)
  else:
    print(b3*(10**18)+b2*(10**9)+b1)
### BUGGY CODE ###

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


def make_divisor_list(num, N):

    if num < 1:
        return 0
    elif num == 1:
        return 1
    else:
        max_num = 1
        for i in range(2, num // N + 1):
            if num % i == 0:
                # 割り切れる=約数
                if num / i >= N:
                    max_num = i
                else:
                    break
        return max_num

print(make_divisor_list(M, N))

### FIXED CODE ###

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

def make_divisor_list(num, N):

    if num < 1:
        return 0
    elif num == 1:
        return 1
    else:
        max_num = 1
        for i in reversed(range(2, num // N + 1)):
            if num % i == 0:
                # 割り切れる=約数
                if num / i >= N:
                    max_num = i
                    break
                #else:
                #    break
        return max_num

print(make_divisor_list(M, N))
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().strip().split()))
Q=int(input())

dp=[0 for n in range(100000)]
for n in range(len(A)):
    dp[A[n]-1]+=1

for n in range(Q):
    B,C=map(int,input().strip().split())
    dp[C-1]+=dp[B-1]
    dp[B-1]=0

    ans=0
    for n in range(1,len(dp)):
        ans+=n*dp[n-1]
    print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().strip().split()))
Q=int(input())

dp=[0 for n in range(100000+1)]
for n in range(len(A)):
    dp[A[n]-1]+=1

init=0
for n in range(1,len(dp)):
    init+=n*dp[n-1]

ans=init
for n in range(Q):
    B,C=map(int,input().strip().split())
    ans=ans-dp[B-1]*B+dp[B-1]*C
    dp[C-1]+=dp[B-1]
    dp[B-1]=0
    print(ans)
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    G = [[] for _ in range(N+1)]
    st = 0
    st_w = 0
    for i in range(N-1):
        u, v, w = (int(i) for i in input().split())
        G[u].append((v, w))
        G[v].append((u, w))
        if i == 0:
            st = u
            st_w = w
    color = [-1] * (N+1)  # 1: 0: white, black, -1: undefined

    def coloring(v, w):
        todo = []
        cur = 0
        color[v] = cur
        todo.append((v, w))
        while todo:
            u, w = todo[-1]
            for next_v, d in G[u]:
                if color[next_v] != -1:
                    continue
                if d % 2 != 0:
                    cur = (cur + 1) % 2
                color[next_v] = cur
                todo.append((next_v, d))
                break
            else:
                _, dist = todo.pop()
                if dist % 2 != 0:
                    cur = (cur + 1) % 2

    coloring(st, st_w)
    for c in color[1:]:
        print(c)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    G = [[] for _ in range(N+1)]
    st = 0
    st_w = 0
    for i in range(N-1):
        u, v, w = (int(i) for i in input().split())
        G[u].append((v, w))
        G[v].append((u, w))
        if i == 0:
            st = u
            st_w = w
    color = [-1] * (N+1)  # 0: white, 1: black, -1: undefined
    from collections import deque

    def coloring(v, w):
        """
        breadth-first search
        a simplified version
        """
        que = deque()
        color[v] = 0
        que.append((v, w))
        while que:
            u, w = que.popleft()
            for v, d in G[u]:
                if color[v] != -1:
                    continue
                if d % 2 != 0:
                    n_col = (color[u] + 1) % 2
                else:
                    n_col = color[u]
                color[v] = n_col
                que.append((v, d))

    coloring(st, st_w)
    for c in color[1:]:
        print(c)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

# なんか身長順でソートすればいいんじゃない？
# 身長差でありえるのは1〜Nなので，身長差が1になるエージェントの組み合わせをだして，それぞれの身長差について調べる
# でも結局全探索になるか？やっぱり配列を作ると同時に答えが独立してうまく求まるようなのがいいよね
# j-i = Aj+Ai となるのが求めるもの，これを変換してiとjの式のみに分離すると，うまく配列を作るだけでうまくいくようになる
# j-Aj = Ai+i となる．こうすると独立しているので,X=i-Ai,Y=Ai+iを作り，setもしくはdictで探索すればすぐです！
# i==jのときはi-i == Ai+Ai が絶対に成立しないので問題ない

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

X=[i+1-A[i] for i in range(N)]
Y=[i+1+A[i] for i in range(N)]
#Y=set(Y) # set使うと同じ要素が減るのでだめ！！！
dicY=dict()
for y in Y:
    if not y in dicY:
        dicY[y]=1
    else:
        dicY[y]+=1
count=0
for x in X:
    if x in Y:
        count+=dicY[x]
print(count)


### FIXED CODE ###

# なんか身長順でソートすればいいんじゃない？
# 身長差でありえるのは1〜Nなので，身長差が1になるエージェントの組み合わせをだして，それぞれの身長差について調べる
# でも結局全探索になるか？やっぱり配列を作ると同時に答えが独立してうまく求まるようなのがいいよね
# j-i = Aj+Ai となるのが求めるもの，これを変換してiとjの式のみに分離すると，うまく配列を作るだけでうまくいくようになる
# j-Aj = Ai+i となる．こうすると独立しているので,X=i-Ai,Y=Ai+iを作り，setもしくはdictで探索すればすぐです！
# i==jのときはi-i == Ai+Ai が絶対に成立しないので問題ない

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

X=[i+1-A[i] for i in range(N)]
Y=[i+1+A[i] for i in range(N)]
#Y=set(Y) # set使うと同じ要素が減るのでだめ！！！
dicY=dict()
for y in Y:
    if not y in dicY:
        dicY[y]=1
    else:
        dicY[y]+=1
count=0
for x in X:
    if x in dicY:
        count+=dicY[x]
print(count)
### BUGGY CODE ###

n=int(input())
List=list(map(int,input().split()))
ans=[]
for i in range(n):
    if((i%2)!=(n%2)):
        ans.insert(0, List[i])
    else:
        ans.append(List[i])

for i in range(n):
    print(ans[i])

### FIXED CODE ###

from collections import deque
n=int(input())
List=input().split()
ans=deque()
for i in range(n):
    if((i%2)!=(n%2)):
        ans.appendleft(List[i])
    else:
        ans.append(List[i])
print(' '.join(map(str,ans)))
### BUGGY CODE ###

N,M=map(int,input().split())
a=list(int(input()) for _ in range(M) )
ans=0
ansn1=0
ansn2=0
mod=1000000007
for i in range(N):

    if i>=2 and  i+1 not in a:
        ans=(ansn1+ansn2)%mod
        ansn2 = ansn1
        ansn1=ans
        continue

    elif i+1 in a:
        ans = 0
        ansn2 = ansn1
        ansn1 = ans
        continue


    if i==0:
        if i+1 not in a:
            ans=1
            ansn2 = 0
            ansn1=ans

    elif i==1:
        if i+1 not in a:
            ans=1+ansn1
            ansn2 = ansn1
            ansn1=ans
        else:
            ans=0
            ansn2=ansn1
            ansn1=ans


print(ans)


### FIXED CODE ###

N,M=map(int,input().split())
a=list(int(input())for _ in range(M))
L=[1 for i in range(N+1)]
dp=[0 for _ in range(N+1)]
#L[0]=0
dp[0]=1
mod=1000000007
for j in a:
    L[j]=0
for i in range(1,N+1):
    if i>=2:
        dp[i]=(dp[i-1]*L[i-1]+dp[i-2]*L[i-2])*L[i]

    elif i==1:
        dp[i]=1
    dp[i]%=mod

print(dp[N])
### BUGGY CODE ###

n = int(input())
t = n
pf = []
i = 2
if n == 1:
    print(0)
    exit()

while i <= n or i ** 2 <= t:
    j = 0
    while n % i == 0:
        n = n // i
        j += 1
    if j > 0:
        pf.append(j)
    i += 1
if len(pf) == 0: pf.append(1)

ans = 0
for i in pf:
    tmp = i
    j = 1
    while j <= tmp:
        tmp -= j
        ans += 1
        j += 1
print(ans)

### FIXED CODE ###

from math import ceil
n = int(input())
pf = []
t = n
if n == 1:
    print(0)
    exit()
for i in range(2, ceil(n ** 0.5) + 1):
    c = 0
    while t % i == 0:
        c += 1
        t //= i
    if c > 0: pf.append(c)
if t != 1: pf.append(1)

ans = 0
for i in pf:
    tmp = i
    j = 1
    while j <= tmp:
        tmp -= j
        ans += 1
        j += 1
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline().rstrip

"""
まず一般に剰余込みでの組み合わせの計算。
n!, (n!)^{-1} mod pの値を配列にまとめておき、nCr = (n!)/(r!)((n-r)!)をO(1)で計算する。

max = (用意する配列の最大長)
mod = （剰余）

(n!)^{-1}の計算は¥Prod_i i^{-1}を計算して求める。
i^{-1} mod pの計算はフェルマーの小定理より、mod pにおいて
0 = p = (p // i) * i + (p % i)
0 = (p // i) + (p % i) * i^{-1}
i^{-1} = -(p // i) * (p % i)^{-1}
"""

max = 10**7
mod = 10**9+7
fact = [1, 1] # fact[n] = (n! mod p)
factinv = [1, 1] # factinv[n] = ((n!)^{-1} mod p)
inv = [0, 1] # inv[n] = (n^{-1} mod p)

for i in range(2, max+1):
    fact.append(fact[-1] * i % mod)
    inv.append(-inv[mod % i] * (mod // i) % mod)
    factinv.append(factinv[-1] * inv[-1] % mod)

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


"""
いよいよ本題。
まずは¥Sum_{0¥le i¥le x, 0¥le j¥le y} _{i+j}C_iを計算する。
実際今回の問題は容易にこれに帰着可能。

¥Sum_{0¥le i¥le x, 0¥le j¥le y} _{i+j}C_i
    = ¥Sum_i (¥Sum_j _{i+j}C_i)
    = ¥Sum_i {(T+1)^i + (T+1)^{i+1} + ... + (T+1)^{i+y})のT^iの係数}
    = ¥Sum_i {¥frac{(1+T)^{i+y+1} - (1+T)^i}{T}のT^iの係数}
    = ¥Sum_i _{i+y+1}C_{i+1}

    = ¥Sum_i _{i+y+1}C_y
    = _{y+1}C_y + _{y+2}C_y + ... + _{y+x+1}C_y
    = {(1+T)^{y+1} + (1+T)^{y+2} + ... (1+T)^{y+x+1}のT^yの係数}
    = {¥frac{(1+T)^{x+y+2} - (1+T)^{y+1}}{T}のT^yの係数}
    = _{x+y+2}C_{y+1} - 1
"""
r1, c1, r2, c2 = map(int, input().split())
a = cmb(r2+c2+2, c2+1) - 1
b = cmb(r1+c2+1, c2+1) - 1
c = cmb(r2+c1+1, r2+1) - 1
d = cmb(r1+c1, r1) - 1
ans = a - b - c + d
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline().rstrip

"""
まず一般に剰余込みでの組み合わせの計算。
n!, (n!)^{-1} mod pの値を配列にまとめておき、nCr = (n!)/(r!)((n-r)!)をO(1)で計算する。

max = (用意する配列の最大長)
mod = （剰余）

(n!)^{-1}の計算は¥Prod_i i^{-1}を計算して求める。
i^{-1} mod pの計算はフェルマーの小定理より、mod pにおいて
0 = p = (p // i) * i + (p % i)
0 = (p // i) + (p % i) * i^{-1}
i^{-1} = -(p // i) * (p % i)^{-1}
"""

max = 10**6 * 2 + 3 # ここでRE出しまくってた。。。
mod = 10**9+7
fact = [1, 1] # fact[n] = (n! mod p)
factinv = [1, 1] # factinv[n] = ((n!)^{-1} mod p)
inv = [0, 1] # inv[n] = (n^{-1} mod p)

for i in range(2, max+1):
    fact.append(fact[-1] * i % mod)
    inv.append(-inv[mod % i] * (mod // i) % mod)
    factinv.append(factinv[-1] * inv[-1] % mod)

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


"""
いよいよ本題。
まずは¥Sum_{0¥le i¥le x, 0¥le j¥le y} _{i+j}C_iを計算する。
実際今回の問題は容易にこれに帰着可能。

¥Sum_{0¥le i¥le x, 0¥le j¥le y} _{i+j}C_i
    = ¥Sum_i (¥Sum_j _{i+j}C_i)
    = ¥Sum_i {(T+1)^i + (T+1)^{i+1} + ... + (T+1)^{i+y})のT^iの係数}
    = ¥Sum_i {¥frac{(1+T)^{i+y+1} - (1+T)^i}{T}のT^iの係数}
    = ¥Sum_i _{i+y+1}C_{i+1}

    = ¥Sum_i _{i+y+1}C_y
    = _{y+1}C_y + _{y+2}C_y + ... + _{y+x+1}C_y
    = {(1+T)^{y+1} + (1+T)^{y+2} + ... (1+T)^{y+x+1}のT^yの係数}
    = {¥frac{(1+T)^{x+y+2} - (1+T)^{y+1}}{T}のT^yの係数}
    = _{x+y+2}C_{y+1} - 1
"""
r1, c1, r2, c2 = map(int, input().split())
a = cmb(r2+c2+2, c2+1) - 1
b = cmb(r1+c2+1, c2+1) - 1
c = cmb(r2+c1+1, r2+1) - 1
d = cmb(r1+c1, r1) - 1
ans = a - b - c + d
print(ans % mod)
### BUGGY CODE ###

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

total_list = []
count = 0
break_flag = False
for i in range(int(10e100)):
    if break_flag:
        break
    for i in range(A):
        total_list.append("b")
        if len(total_list) <= N:
            count += 1
        else:
            break_flag = True
            break
    for i in range(B):
        total_list.append("r")
        if len(total_list) >= N:
            break_flag = True
            break
    if len(total_list) >= N:
        break

print(count)

### FIXED CODE ###

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

amari = N % (A + B)
sho = N // (A + B)

blue_num = 0

if amari < A:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + A

print(blue_num)
### BUGGY CODE ###

#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
r, g, b, n  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ans = 0
for r_ in range(n+1):
    for g_ in range(n+1):
        sum_ = n - (r_ * r + g_ * g)
        if sum_ >= 0 and sum_ % b == 0:
            ans += 1

print(ans)




### FIXED CODE ###

#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
r, g, b, n  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ans = 0
for r_ in range(n+1):
    for g_ in range(n+1):
        sum_ = n - (r_ * r + g_ * g)
        if sum_ >= 0 and sum_ % b == 0:
            ans += 1

print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
path = [[float("inf")]*N for i in range(N)]
ans = [[[float("inf")]]*N for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    path[a-1][b-1] = c
    path[b-1][a-1] = c
    ans[a-1][b-1] = [i]
    ans[b-1][a-1] = [i]
for i in range(N):
    path[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            if path[i][k]+path[k][j] < path[i][j]:
                path[i][j] = path[i][k]+path[k][j]
                ans[i][j] = ans[i][k]+ans[k][j]
total = []
for i in range(N):
    for j in range(N):
        total = ans[i][j] + total
print(M-len(set(total))+1)
        


### FIXED CODE ###

N, M = map(int, input().split())
path = [[float("inf")]*N for i in range(N)]
ans = [[[float("inf")]]*N for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    path[a-1][b-1] = c
    path[b-1][a-1] = c
    ans[a-1][b-1] = [i]
    ans[b-1][a-1] = [i]
for i in range(N):
    path[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            if path[i][k]+path[k][j] < path[i][j]:
                path[i][j] = path[i][k]+path[k][j]
                ans[i][j] = ans[i][k]+ans[k][j]
total = set()
for i in range(N):
    for j in range(N):
        p = set(ans[i][j])
        total = total|p
print(M-len(set(total))+1)
### BUGGY CODE ###

N,M = map(int,input().split())
ls = []
for n in range(N):
  ls.append(list(map(int,input().split())))
ls = sorted(ls, key=lambda x:x[1],reverse=True)

days = {i:0 for i in range(1,M+1)}
sum = 0
max_d = max(days.keys())
for work in ls:
  d = work[0]
  while(d<=max_d):
    if d in days:
      sum+=work[1]
      days.pop(d)
      key = days.keys()
      if len(key)==0:
        max_d = 0
      else:
        max_d = max(days.keys())
      d=M+1
    else:
      d+=1
print (sum)
  
    

### FIXED CODE ###

import heapq
N,M = map(int,input().split())
ls = []
h = []
ans = 0
for n in range(N):
    ls.append(list(map(int,input().split())))
ls = sorted(ls,key=lambda ls:ls[0],reverse=False)
n = 0
for m in range(1,M+1):
    #print (m)
    while(n<N and ls[n][0]<=m ):
        heapq.heappush(h, -ls[n][1])
        n+=1
    if len(h)>0:
        ans -= heapq.heappop(h)
        # print (m,ans)
print (ans)
### BUGGY CODE ###

# https://atcoder.jp/contests/agc030/tasks/agc030_a

def main():
    A, B, C = map(int, input().split())
    deli = 0
    while A > 0 and C > 0:
        deli += 1
        A -= 1
        C -= 1
    # 美味しくないクッキーがなくなった
    while B > 0 and C > 0:
        deli += 2
        B -= 1
        C -= 1

    if C > 0:
        deli += 1

    deli += B
    print(deli)


if __name__ == '__main__':
    main()



### FIXED CODE ###

# https://atcoder.jp/contests/agc030/tasks/agc030_a

def main():
    A, B, C = map(int, input().split())
    deli = 0
    if A > 0 and C > 0:
        eat = min(A, C)
        deli += eat
        A -= eat
        C -= eat

    # 美味しくないクッキーがなくなった, お腹壊してない
    if B > 0 and C > 0:
        eat = min(B, C)
        deli += eat * 2
        B -= eat
        C -= eat
    # お腹壊してない

    if C > 0:
        deli += 1

    deli += B
    print(deli)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r * g * b

c = {"R", "G", "B"}

for i in range(n):
    for j in range(i + 1, n):
        if j - i + j < n:
            if {s[i], s[j], s[j - i + j]} == c:
                ans -= 1

print(ans)

### FIXED CODE ###

n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r * g * b

c = {"R", "G", "B"}

for i in range(n):
    for j in range(i + 1, n):
        if j - i + j < n:
            if {s[i], s[j], s[j - i + j]} == c:
                ans -= 1

print(ans)
### BUGGY CODE ###

# import copy

# standart input
# n = int(input())
# a = list(map(int, input().split()))

N = 13
MOD = 10 ** 9 + 7
s = input()
rs = reversed(s)

dp = [0 for i in range(N)]
dp[0] = 1

for i, si in enumerate(rs):
    nextdp = [0 for i in range(N)]

    for j in range(10):
        c = 0
        if si == "?":
            c = (j * 10 ** i) % N
        elif j == 0:
            c = (int(si) * 10 ** i) % N
        else:
            break

        for k in range(N):
            nextdp[(k + c) % N] += dp[k]
            nextdp[(k + c) % N] %= MOD

    for j in range(N):
        dp[j] = nextdp[j]
    # dp = copy.copy(nextdp)

print(dp[5])


### FIXED CODE ###

# standart input
# n = int(input())
# a = list(map(int, input().split()))

N = 13
MOD = 10 ** 9 + 7

s = input()[::-1]

dp = [0 for i in range(N)]
nextdp = [0 for i in range(N)]
zeros = [0 for i in range(N)]
dp[0] = 1

r = 1
for i, si in enumerate(s):
    nextdp = zeros[:]

    for j in range(10):
        jj = j
        if si == "?":
            pass
            # c = (j * 10 ** i) % N
        elif j == 0:
            jj = int(si)
        else:
            break

        for k in range(N):
            l = (k + r * jj) % N
            nextdp[l] = (nextdp[l] + dp[k]) % MOD

    dp = nextdp
    r = r * 10 % N

print(dp[5])
### BUGGY CODE ###

from sys import stdin
import numpy as np

N = int(input())
A = [int(input()) for i in range(5)]

place = np.zeros(6)
place[0] = N
cnt = 0
while(True):
  cnt += 1
  place[5] += min(A[4], place[4])
  place[4] += min(A[3], place[3]) - min(A[4], place[4])
  place[3] += min(A[2], place[2]) - min(A[3], place[3])
  place[2] += min(A[1], place[1]) - min(A[2], place[2])
  place[1] += min(A[0], place[0]) - min(A[1], place[1])
  place[0] -= min(A[0], place[0])
  if int(place[5]) == N:
    break
    
ans = cnt  
print(ans)

### FIXED CODE ###

from sys import stdin
import numpy as np
import math

N = int(input())
A = [int(input()) for i in range(5)]

time = 4 + math.ceil(N/min(A))
print(time)



"""
# 題意をそのまま表したコード（超遅い）
place = np.zeros(6)
place[0] = N
cnt = 0
while(True):
  cnt += 1
  place[5] += min(A[4], place[4])
  place[4] += min(A[3], place[3]) - min(A[4], place[4])
  place[3] += min(A[2], place[2]) - min(A[3], place[3])
  place[2] += min(A[1], place[1]) - min(A[2], place[2])
  place[1] += min(A[0], place[0]) - min(A[1], place[1])
  place[0] -= min(A[0], place[0])
  if int(place[5]) == N:
    break
    
ans = cnt  
print(ans)
"""