Harryxun/stf_run huggingface dataset:
N, Q = [int(i) for i in input().split()]
S = input()
tdList = reversed([input().split() for _ in range(Q)])

l, r = 0, N - 1
lList, rList = [], []
n_lFlag, n_rFlag = False, False
for td in tdList:
    if td[0] == S[l] and td[1] == "L":
        l += 1
        n_lFlag = True
    elif td[0] == S[r] and td[1] == "R":
        r -= 1
        n_rFlag = True
    if n_lFlag and S[l - 1] == td[0] and td[1] == "R":
        l -= 1
    if n_rFlag and S[r + 1] == td[0] and td[1] == "L":
        r += 1
    if l == N - 1 or r == 0:
        break

ans = 0
if r >= l:
    ans = r - l + 1

print(ans)



### FIXED CODE ###

N, Q = [int(i) for i in input().split()]
S = input()
tdList = reversed([input().split() for _ in range(Q)])

l, r = 0, N - 1
lList, rList = [], []
for td in tdList:
    if td[0] == S[l] and td[1] == "L":
        l += 1
    elif td[0] == S[r] and td[1] == "R":
        r -= 1
    if l != 0 and S[l - 1] == td[0] and td[1] == "R":
        l -= 1
    if r != N - 1 and S[r + 1] == td[0] and td[1] == "L":
        r += 1
    if l > N - 1 or r < 0:
        break

ans = 0
if r >= l:
    ans = r - l + 1

print(ans)
n = input()
 dict = {"1" : "9", "9" : "1"}
 ans = ""
for i in range(len(n)) :
    ans += dict[n[i]]
print(ans)

### FIXED CODE ###

n = input()
dict = {"1" : "9", "9" : "1"}
ans = ""
for i in range(len(n)) :
    ans += dict[n[i]]
print(ans)
def Aizu_PR():
    n = int(input())

    for _ in range(n):
        print(input().replace("Hoshino","Hoshina")

Aizu_PR()


### FIXED CODE ###

def Aizu_PR():
    for _ in range(int(input())):
        print(input().replace("Hoshino","Hoshina"))

Aizu_PR()
n,m=map(int,raw_input().split())

a=[]

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

b=[map(int,raw_input().split() )for i in range(m)]
b=sorted(b,key=lambda x: -x[1])
for i in range(m):
    a.sort()
    if a[0]>b[i][1]:
        break
    for j in range(b[i][0]):
        if a[j] < b[i][1]:
                a[j] = b[i][1]
        else:
           break
print(sum(a))

### FIXED CODE ###

n,m=map(int,raw_input().split())

if n<=5:
    print(0)
elif n<=12:
    print(m/2)
else:
    print(m)
int a=input()
int b=input()

print(a*b)

### FIXED CODE ###

a,b = map(int,input(). split ())
print(a*b)
x, y, z = map(int, raw_input().split())
print (x - z) / (y + z)

### FIXED CODE ###

a, b = raw_input().split()
if a == b:
	print '='
if a < b:
	print '<'
if a > b:
	print '>'
N = int(input())
print(N*500-200*(N//15)

### FIXED CODE ###

N = int(input())
K = N//15
print(800*N-200*K)
import sys
import socket
form math import pi

hostnames = ['N551J', 'F551C', 'X553M']
input_file = 'f1.in'
if socket.gethostname() in hostnames:
    sys.stdin = open(input_file)


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


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    r = read_int()
    return 2 * pi * r


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import socket
from math import pi

hostnames = ['N551J', 'F551C', 'X553M']
input_file = 'a1.in'
if socket.gethostname() in hostnames:
    sys.stdin = open(input_file)


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


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    r = read_int()
    return 2 * pi * r


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()
A = int(input())
B = int(input())
if A <= 8 and B <= 8:
    print('Yay!')
else:
    print(':(')

### FIXED CODE ###

A, B = map(int, input().split())
if A <= 8 and B <= 8:
    print('Yay!')
else:
    print(':(')
n,nc=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(nc)]
c=[list(map(int,input().split())) for _ in range(n)]

dct={}
for x in range(n):
  for y in range(n):
    for ci in range(nc):
      if (ci,(x+y)%3) in dct:
        dct[(ci,(x+y)%3)]+=d[c[x][y]-1][ci]
      else:
        dct[(ci,(x+y)%3)]=d[c[x][y]-1][ci]

def func(x,y,z): #(i+j)%=0をxに、=1をyに、=2をzに塗るときの違和感
  ret=dct[(x,0)]+dct[(y,1)]+dct[(z,2)]
  return ret
ans=float('inf')
for x in range(nc):
  for y in range(nc):
    if x==y:continue
    for z in range(nc):
      if x==z or z==y:continue
      ans=min(ans,func(x,y,z))
print(ans)
#print(dct)

### FIXED CODE ###

n,nc=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(nc)]
c=[list(map(int,input().split())) for _ in range(n)]
from collections import defaultdict
dct=defaultdict(int)
for x in range(n):
  for y in range(n):
    for ci in range(nc):
      if (ci,(x+y)%3) in dct:
        dct[(ci,(x+y)%3)]+=d[c[x][y]-1][ci]
      else:
        dct[(ci,(x+y)%3)]=d[c[x][y]-1][ci]

def func(c1,c2,c3): #(i+j)%=0をc1に、=1をc2に、=2をc3に塗るときの違和感
  ret=dct[(c1,0)]+dct[(c2,1)]+dct[(c3,2)]
  return ret
ans=float('inf')
for c1 in range(nc):
  for c2 in range(nc):
    if c1==c2:continue
    for c3 in range(nc):
      if c1==c3 or c2==c3:continue
      ans=min(ans,func(c1,c2,c3))
print(ans)
#print(dct)
import math
import functools
lcm=lambda x,y:x*y//math.gcd(x,y)
print(functools.reduce(lcm,[int(input())for _ in[0]*int(input())]))

### FIXED CODE ###

import fractions
import functools
lcm=lambda x,y:x*y//fractions.gcd(x,y)
print(functools.reduce(lcm,[int(input())for _ in[0]*int(input())]))
x = int(input())
print(x//500*500*2+x%500//5*5)

### FIXED CODE ###

a = input()
print("Yes" if a[2] == a[3] and a[4] == a[5] else "No")
import math

x, y = map(int,input())

ans = 0

xx = 1
for i in range(x):
    n = i # x：1 の数
    m = (x - i)/2 # x：2 の数
    if y- 2/n == m:
        if max(n,m) == m:
            n,m = m,n
        ans = math.factorial(n) // (math.factorial(n - m) * math.factorial(m))
        break

print(ans)

### FIXED CODE ###

import math

x, y = map(int,input().split())
mod = 10**9+7 #出力の制限

def cmb(n, k,MOD):
    if k > n - k:
        k = n - k
    ans = 1
    for i in range(1, k + 1):
        ans *= n + 1 - i
        ans *= pow(i, MOD - 2, MOD)
        ans %= MOD
    return ans

if (x+y)%3 != 0:
    ans = 0
else:
    m = (2*x - y) //3
    n = x - 2*m
    # print(m,n)
    if m <0 or n < 0 :
        ans = 0
    else:
        ans = cmb(n+m, m, mod)
print(ans)
N = int(input())
A = list(map(int, input().split()))

ball = [0] * N

for i in range(N-1, -1, -1) :
    for j in range(1, N) :
        if i * j >= N :
            break
        bit = (bit + ball[i * j]) % 2
    ball[i] = bit % 2

print(*ball)

### FIXED CODE ###

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

ball = [0] * N
ans = []

for i in range(1, N+1) :
    ballCount = sum(ball[N-i::N-i+1])
    if ballCount % 2 == A[N-i] :
        pass
    else :
        ball[N - i] = 1
        ans.append(N - i + 1)
print(len(ans))
print(*ans)
input()
xs = map(int, input().split())
print(' '.join(map(str,[f(list(xs)) for f in [min,max,sum]])))

### FIXED CODE ###

n = input()
nums = list(map(int, input().split()))
print(min(nums), max(nums), sum(nums))
a,b,c,d = map(int,input().split())
if b<c or d<a:
    print("0")
elif a<c<d<b:
    print(d-c)
elif c<a<b<d:
    print(b-a)
else:
    print(b-c)

### FIXED CODE ###

a,b,c=input()
print("Yes" if a==c else "No")
n, k = map(int, input().split())
d = set([str(i) for i in input().split()])
c = 0
for i in range(1, 11):
    c += n
    t = set(list(str(c)))
    if len(d & t) == 0:
        ans = c
        break
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
d = [str(i) for i in input().split()]
for i in range(n, 10*n+1):
    if len(set(list(str(i))) & set(d)) == 0:
        print(i)
        break
import math
a,b,c,d=map(int,input().split())
base=b-a+1

n_c=math.floor(b/c)-math.ceil(a/c)+1
n_d=math.floor(b/d)-math.ceil(a/d)+1
cd=c*d/math.gcd(c,d)
n_cd=math.floor(b/cd)-math.ceil(a/cd)+1
print(base-n_c-n_d+n_cd)



### FIXED CODE ###

import math
import fractions
a,b,c,d=map(int,input().split())
base=b-a+1
n_c=b//c-(a+c-1)//c+1
n_d=b//d-(a+d-1)//d+1
cd=c*d//fractions.gcd(c,d)
n_cd=b//cd-(a+cd-1)//cd+1
print(base-n_c-n_d+n_cd)
s = input()
print('YES') if s.count('o')+15-k >= 8 else print('NO')

### FIXED CODE ###

s = input()
print('YES') if (s.count('o')+15-len(s) >= 8) else print('NO')
import bisect

n,m,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
sum_a=[a[0]]
for i in range(len(a)-1):
    sum_a.append(sum_a[i]+a[i+1])
sum_b=[b[0]]
for i in range(len(b)-1):
    sum_b.append(sum_b[i]+b[i+1])

#現在のインデックス
idx_a=0
idx_b=0

while idx_a<n or idx_b<m:
    read=''
    #aの読める数
    oset_a=sum_a[idx_a-1] if idx_a>0 else 0
    can_cnt_a=bisect.bisect_right(sum_a,k+oset_a)
    #bの読める数
    oset_b=sum_b[idx_b-1] if idx_b>0 else 0
    can_cnt_b=bisect.bisect_right(sum_b,k+oset_b)
    read='a' if can_cnt_a-idx_a>=can_cnt_b-idx_b else 'b'
    

    #読むほうをPOP
    k-=a[idx_a] if read=='a' else b[idx_b]
    #kを超えた場合ブレーク
    if k<0:
        break
    #カウントアップ
    if read=='a':
        idx_a+=1
    else:
        idx_b+=1
print(idx_a+idx_b)


### FIXED CODE ###

import bisect

n,m,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
sum_a=[a[0]]
for i in range(len(a)-1):
    sum_a.append(sum_a[i]+a[i+1])
sum_b=[b[0]]
for i in range(len(b)-1):
    sum_b.append(sum_b[i]+b[i+1])

#現在のインデックス
idx_a=0
idx_b=0

while idx_a<n or idx_b<m:
    read=''
    #aの読める数
    oset_a=sum_a[idx_a-1] if idx_a>0 else 0
    can_cnt_a=bisect.bisect_right(sum_a,k+oset_a)
    #bの読める数
    oset_b=sum_b[idx_b-1] if idx_b>0 else 0
    can_cnt_b=bisect.bisect_right(sum_b,k+oset_b)
    read='a' if can_cnt_a-idx_a>can_cnt_b-idx_b else 'b'
    if idx_a==n:
        read='b'
    if idx_b==m:
        read='a'
    

    #読むほうをPOP
    k-=a[idx_a] if read=='a' else b[idx_b]
    #kを超えた場合ブレーク
    if k<0:
        break
    #カウントアップ
    if read=='a':
        idx_a+=1
    else:
        idx_b+=1
print(idx_a+idx_b)
a,b=map(int,input().split())
ans=0
for i in rnage(0,b,a-1):
  ans+=1
print(ans+1)

### FIXED CODE ###

a,b=map(int,input().split())
ans=0
for i in range(1,b,a-1):
  ans+=1
print(ans)
N = str(input())
a, b, c, d = N[0], N[1], N[2], N[3]

ans = "No"
if a == b and b =A= c:
  ans = "Yes"
elif b == c and c == d:
  ans ="Yes"
    
    
print(ans)


### FIXED CODE ###

N = str(input())
a, b, c, d = N[0], N[1], N[2], N[3]

ans = "No"
if a == b and b == c:
  ans = "Yes"
elif b == c and c == d:
  ans ="Yes"
    
    
print(ans)
N, M = map(int, input().split())
A = list(map(int, input().split()))
daystofinish = sum(A)
print(N-daystofinish)
N, M = map(int, input().split())
A = list(map(int, input().split()))
daystofinish = sum(A)
if N-daystofinish < 0:
    print(-1)
else:
    print(N-daystofinish)

### FIXED CODE ###

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

x = n - sum(a)
print(x if x >= 0 else -1)
n, m = map(int, input().split())

a = [[0, 0] for i in range(n)]

c = [[0, 0] for i in range(m)]

for i in range(n):
    a[i][0], a[i][1] = map(int, input().split())

for i in range(n):
    c[i][0], c[i][1] = map(int, input().split())

index = 0

for i in range(n):
    for j in range(m):
        if j == 0 :
            k = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]) +1

        di = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
        if di < k:
            index = j + 1
            k = di
    print(index)


### FIXED CODE ###

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

a = [[0, 0] for i in range(n)]

c = [[0, 0] for i in range(m)]

for i in range(n):
    a[i][0], a[i][1] = map(int, input().split())

for i in range(m):
    c[i][0], c[i][1] = map(int, input().split())

index = 0


for i in range(n):
    for j in range(m):
        if j == 0 :
            k = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]) +1

        di = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
        if di < k:
            index = j + 1
            k = di
    print(index)
n = input()
a = int(n[0:2])
b = int(n[2:])
if 1 <= a <= 12 and 1 <= b <= 12:
	print('AMBIGUOUS')
elif 1 <= a <= 12 and b > 12:
	print('MMYY')
elif 1 <= b <= 12 and a > 12:
	print('YYMM')
else:
print('NA')


### FIXED CODE ###

#!/usr/bin/env python3
n,k = map(int, input().split())
S = list(input())
S[k-1]= S[k-1].lower()
print("".join(S))
import math

def routing(s,g,route):
    ans=[]
    i=g
    while i!=-1:
        ans.append(i+1)
        i=route[i]
    return ans[::-1]

inf=100000
while True:
    n=input()
    if n==0:break
    L=[[inf]*n for i in range(n)]
    for i in range(n):
        L[i][i]=0
    B=[map(int,raw_input().split()) for i in range(n)]
    for i in range(n-1):
        for j in range(i+1,n):
            ba,xa,ya=B[i]
            bb,xb,yb=B[j]
            ba,bb=ba-1,bb-1
            d=math.sqrt(pow(xa-xb,2)+pow(ya-yb,2))
            if d<=50:
                L[ba][bb]=L[bb][ba]=d

    m=input()
    for p in range(m):
        s,g=map(int,raw_input().split())
        s,g=s-1,g-1
        n=len(L)
        done=[s]
        dist=[inf]*n
        dist[s]=0
        route=[-1]*n
        i=s
        while len(done)<n:
            for j in range(n):
                if j in done:
                    continue
                if dist[j]>dist[i]+L[i][j]:
                    dist[j]=dist[i]+L[i][j]
                    route[j]=i
            min_node_size=inf
            for v,w in enumerate(dist):
                if v not in done and w<min_node_size:
                    min_node_size=w
                    min_node_num=v
            i=min_node_num
            done.append(min_node_num)
        print 'NA'

### FIXED CODE ###

import math

def dijkstra(s):
    d=[inf]*n
    pi=[inf]*n
    visited=[False]*n
    d[s]=0
    pi[s]=-1
    while True:
        mincost=inf
        for i in range(n):
            if not visited[i] and d[i]<mincost:
                mincost=d[i]
                u=i
        if mincost==inf:
            break
        visited[u]=True
        for v in range(n):
            if visited[v] or L[u][v]==inf:
                continue
            if d[u]+L[u][v]<d[v]:
                d[v]=d[u]+L[u][v]
                pi[v]=u
    return pi

def routing(pi,g):
    ans=[]
    i=g
    while i!=-1:
        ans.append(i+1)
        i=pi[i]
    return ans[::-1]

inf=100000
while True:
    n=input()
    if n==0:break
    L=[[inf]*n for i in range(n)]
    for i in range(n):
        L[i][i]=0
    B=[map(int,raw_input().split()) for i in range(n)]
    for i in range(n-1):
        for j in range(i+1,n):
            ba,xa,ya=B[i]
            bb,xb,yb=B[j]
            ba,bb=ba-1,bb-1
            d=math.sqrt(pow(xa-xb,2)+pow(ya-yb,2))
            if d<=50:
                L[ba][bb]=L[bb][ba]=d
    m=input()
    for i in range(m):
        s,g=map(int,raw_input().split())
        s,g=s-1,g-1
        pi=dijkstra(s)
        if pi[g]==inf:
            print "NA"
        else:
            ans=routing(pi,g)
            print " ".join(map(str,ans))
K = int(input())
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
F = K +1
print(list[F])

### FIXED CODE ###

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
if K < 32:
    print(list[K-1])
else:
    print(list[31])
import math
a,b,c=map(int,input().split())
eps = 0.00000000000001
if 4*a*b<(c-a-b)**2 and (c-a-b) > 0:
	print('Yes')
else:
	print('No')

### FIXED CODE ###

k = int(input())
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(x[k-1])
from collections import deque

n,m=map(int,input().split())
l=list(map(int,input().split()))
l=[i/2 for i in l]
if n==1:
  if (m//l[0])%2==0:
    print(int((m//l[0])/2))
  else:
    print(int((m//l[0]+1)/2))
  exit()
  
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

s=set(l)
l=set(l)
a1=l.pop()
a2=l.pop()
g=gcd(a1,a2)
lcm=g*(a1/g)*(a2/g)
d=1

while l:
  a=l.pop()
  d=gcd(lcm,a)
  lcm=d*(a/d)*(lcm/d)
  

if lcm>m:
  print(0)
  exit()
  
for a in s:
  if (lcm/a)%2==0:
    print(0)
    break
else:
  if (m//lcm)%2==0:
    print(int((m//lcm)/2))
  else:
    print(int((m//lcm+1)/2))


### FIXED CODE ###

#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))

def lcm(a,b):
    g=math.gcd(a,b)
    return b*(a//g)
l=a[0]//2
for i in range(n):
    r=a[i]//2
    l=lcm(l,r)
for i in range(n):
    if (l//(a[i]//2))%2==0:
        print(0)
        exit()
res=m//l
print((res+1)//2)
s = int(input())
l = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']
print(l[l.index(s)+1])

### FIXED CODE ###

s = input()
l = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']
print(l[l.index(s)+1])
n=int(input())
a=list(map(int,input().split()))
c,d=dict(),dict()
for i in range(n):
    if i+1-a[i] in c:
        c[a[i]-i-1]+=1
    else:
        c[a[i]-i-1]=1
    if i+1+a[i] in d:
        d[a[i]+i+1]+=1
    else:
        d[a[i]+i+1]=1
ans=0
for i in c:
    if i in d:
        ans+=(c[i]*d[i])
print(ans)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
c,d=dict(),dict()
for i in range(n):
    if i+1-a[i] in c:
        c[i+1-a[i]]+=1
    else:
        c[i+1-a[i]]=1
    if i+1+a[i] in d:
        d[i+1+a[i]]+=1
    else:
        d[i+1+a[i]]=1
ans=0
for i in c:
    if i in d:
        ans+=(c[i]*d[i])
print(ans)
cond = map(int, raw_input().split())
a = cond[0]
b = cond[1]

print "(a*b) (a*2 + b*2)"

### FIXED CODE ###

cond = map(int, raw_input().split())
a = cond[0]
b = cond[1]

print (a*b),
print (a*2 + b*2)
N = int(input())
a = map(int,raw_input().split())

amax = (max(a))
amin = (min(a))

res = abs(amax-amin)
print res 

### FIXED CODE ###

N = int(input())

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

amax = (max(a))
amin = (min(a))

res = abs(amax-amin)
print (res)
import sys
from collections import Counter
S = ""
for s in sys.stdin():
    S += s
m = Counter(S)
for i in 'abcdefghijklmnopqrstuvwxyz':
    print(i, ":", m[i])



### FIXED CODE ###

import sys
from collections import Counter
m = Counter(sys.stdin.read().lower())
for i in 'abcdefghijklmnopqrstuvwxyz':
    print(i, ":", m[i])
a = lma()
f = 1
c =0
while f:
    if (a[0] == a[1] and a[0] == a[2]) :
        c=-1
        break
    if a[0]%2==1 or a[1]%2==1 or a[2]%2 ==1:break
    a[0],a[1],a[2] = (a[1]+a[2])/2,(a[0]+a[2])/2,(a[1]+a[0])/2
    c+=1
print(c)

### FIXED CODE ###

def lma():return list(map(int, input().split()))#x or y
a = lma()
f = 1
c =0
while f:
    if a[0]%2==1 or a[1]%2==1 or a[2]%2 ==1:break
    if (a[0] == a[1] and a[0] == a[2]) :
        c=-1
        break
    a[0],a[1],a[2] = (a[1]+a[2])/2,(a[0]+a[2])/2,(a[1]+a[0])/2
    c+=1
print(c)
a,b = int(input())
b = int(input())
if a == b:
    print("EQUAL")
elif a > b:
    print("GREATER")
else:
    print("LESS")

### FIXED CODE ###

a = int(input())
b = int(input())
if a == b:
    print("EQUAL")
elif a > b:
    print("GREATER")
else:
    print("LESS")
if __name__=="__main__":
  N=int(input())
  x=[int(i) for i in input().split()]
  ans+=0
  for i in range(1,len(x)):
    if x[i]<x[i-1]:
      ans+=(x[i-1]-x[i])
      x[i]+=ans
  print(ans)
      
    

### FIXED CODE ###

if __name__=="__main__":
  N=int(input())
  x=[int(i) for i in input().split()]
  ans=0
  for i in range(1,len(x)):
    if x[i]<x[i-1]:
      #print(x[i-1]-x[i])
      ans+=(x[i-1]-x[i])
      x[i]+=(x[i-1]-x[i])
  print(ans)
n=int(input())
a=list(map(int,input().split()))
aset=list(set(a))
ans=0
al=[0]*n
for i in a:
    al[i]+=1
for j in aset:
    k=al[j]
    ans+=(k*(k-1))//2
for u in a:
    print(ans-al[u]+1)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
aset=list(set(a))
ans=0
al=[0]*200000
for i in a:
    al[i]+=1
for j in aset:
    k=al[j]
    ans+=(k*(k-1))//2
for u in a:
    print(ans-al[u]+1)
n = 0
X = 0
while X<1:
	# print(L)
	K = len(L)-1
	# print(K)
	for i in range(K):
		if L[i]+L[i+1]==1:
			L.pop(i)
			L.pop(i)
			n=n+1
			break
		elif i == K-1:
			X=1

# print(L)
print(n*2)


### FIXED CODE ###

S =list(input())
L =list(map(int,S))

print(min(L.count(0),L.count(1))*2)
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a, b, c = map(int, raw_input().split())
sum = a+b+C
if sum == 17:
  	print "YES"
else: 
	print "NO"


### FIXED CODE ###

# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a, b, c = map(int, raw_input().split())
sum = a+b+c
if sum == 17:
  print "YES"
else: 
  print "NO"
x,y,a,b,c = map(int, input().split())
A = list(map(int, input().split())) 
B = list(map(int, input().split())) 
C = list(map(int, input().split())) 

A.sort()
B.sort()
C.sort(reverse=True)

X = A[len(A)-x:]
Y = B[len(B)-y:]

print(X,Y,C)

xi = 0
yi = 0
ci = 0
for ci in range(c):
    if C[ci] <= X[xi] and C[ci] <= Y[yi]:
        break
    
    if X[xi] < Y[yi]:
        if C[ci] > X[xi]:
            X[xi] = C[ci]
            xi = xi + 1
    else:
        if C[ci] > Y[yi]:
            Y[yi] = C[ci]
            yi = yi + 1

print(X,Y)
print(sum(X)+sum(Y))






### FIXED CODE ###


x,y,a,b,c = map(int, input().split())
A = list(map(int, input().split())) 
B = list(map(int, input().split())) 
C = list(map(int, input().split())) 

A.sort()
B.sort()
C.sort(reverse=True)

X = A[len(A)-x:]
Y = B[len(B)-y:]

#print(X,Y,C)

xi = 0
yi = 0
ci = 0
for ci in range(c):
    #print(ci,xi,yi)
    if xi < len(X) and yi < len(Y):
        if C[ci] <= X[xi] and C[ci] <= Y[yi]:
            break
        
        if X[xi] < Y[yi]:
            if C[ci] > X[xi]:
                X[xi] = C[ci]
                xi = xi + 1
        else:
            if C[ci] > Y[yi]:
                Y[yi] = C[ci]
                yi = yi + 1
                
    elif xi < len(X):
        if C[ci] <= X[xi]:
            break
        
        if C[ci] > X[xi]:
            X[xi] = C[ci]
            xi = xi + 1
        
    elif yi < len(Y):
        if C[ci] <= Y[yi]:
            break
        
        if C[ci] > Y[yi]:
            Y[yi] = C[ci]
            yi = yi + 1
            
    else:
        break

print(sum(X)+sum(Y))
N = int(input())
D = int(input())
if N % (2*D+1) == 0:
    print(N // (2*D+1))
else:
    print(N// (2*D+1) + 1)

### FIXED CODE ###

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

if N % (2*D+1) == 0:
    print(N // (2*D+1))
else:
    print(N// (2*D+1) + 1)