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

burgerList=[""]*51
def burger(level):
    if burgerList[level]=="":
        if level==0:
            burgerList[level]="P"
        else:
            burgerList[level]="B"+burger(level-1)+"P"+burger(level-1)+"B"
    return burgerList[level]
 
n,x=[int(x) for x in input().split()]
print(burger(n)[:x].count("P"))

### FIXED CODE ###

# coding: utf-8
# Your code here!
n,x=[int(x) for x in input().split()]
burgurnum=["" for _ in [0]*51]
burgurnumP=["" for _ in [0]*51]
def burgurNumFunc(level):
    if burgurnum[level]=="":
        if level==0:
            burgurnum[level]=1
        else:
            burgurnum[level]=burgurNumFunc(level-1)*2+3
    return burgurnum[level]
def burgurnumPFunc(level):
    if burgurnumP[level]=="":
        if level==0:
            burgurnumP[level]=1
        else:
            burgurnumP[level]=burgurnumPFunc(level-1)*2+1
    return burgurnumP[level]
    
    
def burger(num,level):
    if level==0:
        return 1
    elif num==1:
        return 0
    elif 1<num<=1+burgurNumFunc(level-1):
        return burger(num-1,level-1)
    elif num==burgurNumFunc(level-1)+2:
        return burgurnumPFunc(level-1)+1
    elif burgurNumFunc(level-1)+2<num<=burgurNumFunc(level-1)*2+2-1:
        return burgurnumPFunc(level-1)+1+burger(num - burgurNumFunc(level-1)-2,level-1)
    else:
        return burgurnumPFunc(level-1)*2+1
    

print(burger(x,n))
### BUGGY CODE ###

n, k = map(int, input().split())
s = input()

if(n != 1):
    sl = []
    c = 1
    for i in range(n):
        if (i == 0):
            if (s[i] == "1"):
                sl.append(0)
        if (i != 0):
            if (s[i] == s[i-1]):
                c += 1
            else:
                sl.append(c)
                c = 1
    sl.append(c)

    cl = []
    for i in range(n):
        st = i - k
        ed = i + k+1
        if (st < 0):
            st = 0
        if (ed > len(sl)):
            ed = len(sl)
        if (k % 2 == 1):  # kが奇数の時、0の箇所（すなわちiが偶数の箇所）を中心に反転
            if (i % 2 == 0):
                cl.append(sum(sl[st:ed]))
        else:  # kが偶数の時、1の箇所（すなわちiが奇数の箇所）を中心に反転
            if (i % 2 == 1):
                cl.append(sum(sl[st:ed]))

    print(max(cl))
else:
    print(1)

### FIXED CODE ###

n, k = map(int, input().split())
s = str(input())

sl = []
c = 1
if (s[0] == "1"):
    sl.append(0)
for i in range(n):
    if (i != 0):
        if (s[i] == s[i-1]):
            c += 1
        else:
            sl.append(c)
            c = 1
sl.append(c)

ruisekiwa = [0]
sums = []
ans = 0
w = 2*k+1

if (w > len(sl)):
    print(n)
    exit()
for i in range(len(sl)):
    ruisekiwa.append(ruisekiwa[i] + sl[i])
# print(sl)
# print(ruisekiwa)
for i in range(len(sl)):
    if(k % 2 == 1 and i % 2 == 0 or k % 2 == 0 and i % 2 == 1):
        left = i-k
        if (left < 0):
            left = 0
        right = i + k+1
        if (right >= len(ruisekiwa)):
            right = len(ruisekiwa)-1
        # print(ruisekiwa[right], "-", ruisekiwa[left],
        #      "=", ruisekiwa[right]-ruisekiwa[left])
        ans = max(ans, ruisekiwa[right]-ruisekiwa[left])
print(ans)
### BUGGY CODE ###

N, X, Y = map(int, input().split())

INF = 1 << 30
dis = [ [abs(i-j) if abs(i-j) < 2 else INF for i in range(N)] for j in range(N)]
dis[X-1][Y-1] = 1
dis[Y-1][X-1] = 1

for k in range(N):
  for i in range(N):
    for j in range(N): dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j])

for i in range(1, N):
  ans = 0
  for j in range(N): ans += dis[j].count(i)
  print(ans//2)

### FIXED CODE ###

N, X, Y = map(int, input().split())

X -= 1
Y -= 1

ans = [0] * (N-1)

for i in range(N):
  for j in range(i+1, N):
    ans[min(j-i, abs(X-i)+1+abs(Y-j))-1] += 1

for x in ans: print(x)
### BUGGY CODE ###

# 各々の要素が何番目に何回数えられるかを考える。
import sys

input = sys.stdin.buffer.readline

n = int(input())
C = list(map(int, input().split()))
C.sort(reverse=True)
mod = 10 ** 9 + 7
N = n + 5
bikkuri = [0] * N
bikkuri[0] = 1
gyaku = [0] * N
for i in range(1, N):
    bikkuri[i] = (i * bikkuri[i - 1]) % mod
gyaku[N - 1] = pow(bikkuri[N - 1], mod - 2, mod)
for i in range(N - 1, 0, -1):
    gyaku[i - 1] = (gyaku[i] * i) % mod


def comb(n, r):
    if r < 0 or n - r < 0:
        return 0
    return (bikkuri[n] * gyaku[r] * gyaku[n - r]) % mod


ans = 0
for i in range(n):
    for a in range(i + 1):
        ans += comb(i, a) * (a + 1) * C[i] * pow(2, n - (i + 1), mod)
        ans %= mod
ans *= pow(2, n, mod)
ans %= mod
print(ans)


### FIXED CODE ###

# 各々の要素が何番目に何回数えられるかを考える。
import sys

input = sys.stdin.buffer.readline

n = int(input())
C = list(map(int, input().split()))
C.sort(reverse=True)
mod = 10 ** 9 + 7
N = n + 5
bikkuri = [0] * N
bikkuri[0] = 1
gyaku = [0] * N
for i in range(1, N):
    bikkuri[i] = (i * bikkuri[i - 1]) % mod
gyaku[N - 1] = pow(bikkuri[N - 1], mod - 2, mod)
for i in range(N - 1, -1, -1):
    gyaku[i - 1] = (gyaku[i] * i) % mod


def comb(n, r):
    if r < 0 or n - r < 0:
        return 0
    return (bikkuri[n] * gyaku[r] * gyaku[n - r]) % mod


ans = 0
for i in range(n):
    ans += (i + 2) * C[i] * pow(2, 2 * n - 2, mod)
    ans %= mod
print(ans)
### BUGGY CODE ###

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

A_sum = [0] + [sum(A[:i+1]) for i in range(len(A))]
B_sum = [0] + [sum(B[:i+1]) for i in range(len(B))]
B_sum.append(10**20)

res = 0
for i in range(len(A_sum)):
    low = 0
    high = len(B_sum)
    while high - low > 1:
        mid = (low + high) // 2
        if A_sum[i] + B_sum[mid] <= K:
            low = mid
        else:
            high = mid
    if A_sum[i] + B_sum[low] <= K:
        res = max(res, i + low)

print(res)


### FIXED CODE ###

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

A_sum = [0]
for i in range(N):
    A_sum.append(A_sum[i] + A[i])
B_sum = [0]
for i in range(M):
    B_sum.append(B_sum[i] + B[i])
B_sum.append(10**10)

res = 0
for i in range(len(A_sum)):
    low = 0
    high = len(B_sum)
    while high - low > 1:
        mid = (low + high) // 2
        if A_sum[i] + B_sum[mid] <= K:
            low = mid
        else:
            high = mid
    if A_sum[i] + B_sum[low] <= K:
        res = max(res, i + low)

print(res)
### BUGGY CODE ###

import sys
e=sys.stdin.readlines()
while 1:
 H,W=map(int,e[0].split())
 if H<1:break
 s=[[*map(int,r.split())]for r in e[1:H+1]]
 a=0
 for x in range(2**H):
  t=[[c^1>>b&x for c in map(int,r)]for r,b in zip(s,range(H))]
  a=max(a,sum(max(sum(c),H-sum(c))for c in zip(*t)))
 print(a)
 del e[:H+1]


### FIXED CODE ###

def v():
 for e in iter(input,'0 0'):
  r=int(e.split()[0])
  d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
  a=0
  for m in range(1<<~-r):
   t=0
   for s in d:
    c=bin(m^s).count('1')
    t+=max(c,r-c)
   if a<t:a=t
  print(a)
if'__main__'==__name__:v()
### BUGGY CODE ###

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

def cost(a, b):
    return abs(h[a] - h[b])

c = [0] * N
for i in range(1, N):
    c[i] = min(
        [cost(i, i-k)+c[i-k] for k in range(1, min(K, i)+1)]
        )

print(c[-1])



### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
 
def cost(a, b):
    return abs(h[a] - h[b])
 
c = [0] * N
for i in range(1, N):
    c[i] = min(cost(i, i-k)+c[i-k] for k in range(1, min(K, i)+1))
 
print(c[-1])
### BUGGY CODE ###

N = int(input())
lst = [int(i) for i in input().split()]
lst.insert(0, 0)
res = [0]
for i in range(1, N+1):
    t = lst[:]
    del(t[i])
    res.append(sum([abs(t[i] - t[i-1]) for i in range(1, N)]) + abs(t[-1]))

for i in range(1, N+1):
    print(res[i])


### FIXED CODE ###

N = int(input())
As = [0] + [int(a) for a in input().split()] + [0]

total = 0
for i in range(N+1):
    total += abs(As[i+1]-As[i])

for i in range(1,N+1):
    if As[i-1] == As[i] or As[i] == As[i+1] or \
            (As[i-1] < As[i]) == (As[i] < As[i+1]):
        print(total)
    else:
        da = abs(As[i-1]-As[i])
        db = abs(As[i]-As[i+1])
        print(total-2*min(da,db))
### BUGGY CODE ###

X,K,D = map(int,input().split())

c = X

for i in range(K):
  if c >= 0:
    if abs(c-D) <= abs(c):
      c = c - D
    else:
      c = c + D
  if c < 0:
    if abs(c+D) <= abs(c):
      c = c + D
    else:
      c = c - D
  i += 1


print(abs(c))

### FIXED CODE ###

X,K,D = map(int,input().split())

# 絶対値を取れば正の座標だけ考えれば済む
X = abs(X)

# D>Xなら移動1回だけで原点飛び越える
if D > X:
  #偶数の場合はそのままで奇数の場合はD-X
  if K % 2 == 0:
    print(X)
  else:
    print(abs(D-X))
    
# K回移動してもまだ正のときは最後の座標
else:
  if X//D >= K:
    print(X - K*D)
# その後の移動の検討
  else:
    tmp = X - (X//D)*D
    if (K - X//D) % 2 == 0:
      print(tmp)
    else:
      print(min(abs(tmp-D),tmp+D))
### BUGGY CODE ###

n,m=map(int,input().split())
danger=[int(input()) for i in range(m)]
steps=[0]*(n+1)
steps[0]=1

if 1 in danger:
    steps[1]=0
else:
    steps[1]=1

for this_step in range(2,n+1):
    if this_step in danger:
        ap=0
    else:
        steps[this_step]=steps[this_step-1]+steps[this_step-2]

print(steps[-1]%1000000007)

### FIXED CODE ###

n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
a = set(a)
mod = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
for i in range(2,n+1):
    if i not in a:
        dp[i] = dp[i-1]+dp[i-2]
print(dp[-1]%mod)
### BUGGY CODE ###

def solve(p):
    cnt = 0
    for i in range(len(A)):
        for j in range(len(B)):
            for k in range(len(C)):
                if A[i] + B[j] + C[k] < p:
                    break
                cnt +=1
                if cnt >=k:
                    return True
    return False

def find(p):
    num = []
    for i in range(len(A)):
        for j in range(len(B)):
            for k in range(len(C)):
                if A[i] + B[j] + C[k] <= p:
                    break
                else:
                    num.append(A[i] + B[j] + C[k])
    return num

X,Y,Z,K=map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

max_taste = max(A) + max(B)+max(C)

M = max_taste
m = 0
n = (M+m) //2
while m!=n:
    if solve(n):
        M = n
    else:
        m = n
    n = (M+m) //2
    #print(M, m, n)
        
item = sorted(find(n), reverse=True)
if len(item) >=K:
    for i in range(K):
        print(item[i])
else:
    for i in range(len(item)):
        print(item[i])
    for _ in range(K- len(item)):
        print(n)

### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)

sumAB = sorted([ai + bi for ai in a for bi in b],reverse=True)[:k]
final_ans = sorted([ci + abi for ci in c for abi in sumAB],reverse = True)[:k]

for i in range(k):
    print(final_ans[i])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(200000)
def main():
    input = sys.stdin.readline
    N, M = map(int,input().split())
    G = [[[],[],[]] for k in range(N)]

    for k in range(M):
        u, v = map(int,input().split())
        u -= 1
        v -= 1
        G[u][0] += [v]
        G[u][1] += [v]
        G[u][2] += [v]

    S, T = map(int,input().split())
    S -= 1
    T -= 1
    D1 = [[200000,200000,200000] for k in range(N)]
    D1[S][0] = 0
    def dfs1(now, dist):
        for tsugi in G[now][1]:
            if D1[tsugi][1] > dist + 1:
                D1[tsugi][1] = dist + 1
                dfs2(tsugi, dist+1)
    def dfs2(now, dist):
        for tsugi in G[now][2]:
            if D1[tsugi][2] > dist + 1:
                D1[tsugi][2] = dist + 1
                dfs3(tsugi, dist+1)
    def dfs3(now, dist):
        for tsugi in G[now][0]:
            if D1[tsugi][0] > dist + 1:
                D1[tsugi][0] = dist + 1
                dfs1(tsugi, dist+1)

    dfs1(S,0)

    if D1[T][0]%3 == 0:
        print(D1[T][0]//3)
    else:
        print(-1)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import deque
def main():
    INF = float("inf")
    input = sys.stdin.readline
    N, M = map(int,input().split())
    G = [[] for k in range(N)]
    for k in range(M):
        u, v = map(int,input().split())
        u -= 1
        v -= 1
        G[u] += [v]
    S, T = map(int,input().split())
    S -= 1
    T -= 1
    D = [[INF,INF,INF] for k in range(N)]
    D[S][0] = 0
    Q = deque([[S,0]])
    while len(Q) > 0:
        t = Q.popleft()
        ima = t[0]
        k = t[1]
        for tsugi in G[ima]:
            if D[tsugi][(k+1)%3] != INF:
                pass
            else:
                D[tsugi][(k+1)%3] = D[ima][k] + 1
                Q.append([tsugi,(k+1)%3])
    if D[T][0] == INF or D[T][0]%3 != 0:
        print(-1)
    else:
        print(D[T][0]//3)

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

s = input()
k = int(input())

keys = []
for start in range(len(s)):
  for end in range(start+1, len(s)+1):
    key = s[start:end]
    if key in keys:
      continue
    if len(keys) < 5:
      keys.append(key)
      keys.sort()
    elif keys[-1] > key:
      keys.append(key)
      keys.sort()
      keys = keys[:-1]
print(keys[k-1])

### FIXED CODE ###

s = input()
k = int(input())

keys = []
for start in range(len(s)):
  for end in range(start+1, min(start+6, len(s)+1)):
    key = s[start:end]
    if key in keys:
      continue
    if len(keys) < 5:
      keys.append(key)
      keys.sort()
    elif keys[-1] > key:
      keys.append(key)
      keys.sort()
      keys = keys[:-1]
print(keys[k-1])
### BUGGY CODE ###

import math
N = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
m = 0
st_n = a[0]
st_r = a[1]
for n in range(N-1):
    for r in range(n+1,N):
        if a[r] != 0:
            cn = math.factorial(a[n])//(math.factorial(a[r])*math.factorial(a[n]-a[r]))
            if m < cn:
                st_n = a[n]
                st_r = a[r]
                m = cn

print(st_n,st_r)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
st_n = a[0]
st_r = a[1]
m = st_r*(st_n-st_r)
for r in range(2,N):
    cn = a[r]*(st_n-a[r])
    if m < cn:
        st_r = a[r]
        m = cn
print(st_n,st_r)
### BUGGY CODE ###

n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]
t = [[] for _ in range(n)]
for p, y in data:
  t[p - 1].append(y)
for i in range(n):
  t[i].sort()
for p, y in data:
  nth = t[p - 1].index(y) + 1
  print("%06d%06d" % (p, nth))


### FIXED CODE ###

from bisect import bisect_left
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]
t = [[] for _ in range(n)]
for p, y in data:
  t[p - 1].append(y)
for i in range(n):
  t[i].sort()
for p, y in data:
  nth = bisect_left(t[p - 1], y) + 1
  print("%06d%06d" % (p, nth))
### BUGGY CODE ###

def main():
    N = int(input())
    X = input()
    X_count = X.count("1")
    X = int(X, 2)
    ans = []
    
    def popcount(x):
        '''xの立っているビット数をカウントする関数
        (xは64bit整数)'''

        # 2bitごとの組に分け、立っているビット数を2bitで表現する
        x = x - ((x >> 1) & 0x5555555555555555)

        # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
        x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

        x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
        x = x + (x >> 8) # 16bitごと
        x = x + (x >> 16) # 32bitごと
        x = x + (x >> 32) # 64bitごと = 全部の合計
        return x & 0x0000007f

    for i in range(N-1, -1, -1):
        count = 1
        target = 1 << i
        Xi = X ^ target

        if X_count == 1 and target & X:
            ans.append(0)
            continue

        if target & X:
            Xi %= (X_count - 1)
        else:
            Xi %= (X_count + 1)

        # process
        # Xi はN-1以下
        while Xi:
            count += 1
            Xi %= popcount(Xi)

        ans.append(count)
    
    print(*ans, sep="\n")
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N = int(input())
    X = input()
    
    def popcount(x):
        '''xの立っているビット数をカウントする関数
        (xは64bit整数)'''

        # 2bitごとの組に分け、立っているビット数を2bitで表現する
        x = x - ((x >> 1) & 0x5555555555555555)

        # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
        x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

        x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
        x = x + (x >> 8) # 16bitごと
        x = x + (x >> 16) # 32bitごと
        x = x + (x >> 32) # 64bitごと = 全部の合計
        return x & 0x0000007f

    ans = []
   
    f = [0] * N
    # preprocess 1
    for i in range(1, N):
        pc = popcount(i)
        j =  i % pc
        f[i] = f[j] + 1
    
    # preprocess 2
    X_COUNT = X.count("1")
    X = tuple(map(int, tuple(X)))
    rem_plus = [0] * N
    rem_minus = [0] * N
    two_factor = 1
    for i in range(N):
        rem_plus[i] = two_factor
        two_factor *= 2
        two_factor %= (X_COUNT+1)

    if X_COUNT > 1:
        two_factor = 1
        for i in range(N):
            rem_minus[i] = two_factor
            two_factor *= 2
            two_factor %= (X_COUNT-1)


    X_rem_plus = 0
    X_rem_minus = 0
    two_factor = 1
    for c in X[::-1]:
        X_rem_plus += two_factor*c
        X_rem_plus %= (X_COUNT+1)
        two_factor *= 2
        two_factor %= (X_COUNT+1)
    
    if X_COUNT > 1:
        two_factor = 1
        for c in X[::-1]:
            X_rem_minus += two_factor*c
            X_rem_minus %= (X_COUNT-1)
            two_factor *= 2
            two_factor %= (X_COUNT-1)
    
    for i, c in enumerate(X):
        if c:
            if X_COUNT > 1:
                rem = X_rem_minus - rem_minus[N-1-i]
                rem %= (X_COUNT-1)
                ans.append(f[rem]+1)
            elif X_COUNT == 1:
                ans.append(0)
            else:
                ans.append(0)
        else:
            rem = X_rem_plus + rem_plus[N-1-i]
            rem %= (X_COUNT+1)
            ans.append(f[rem]+1)
   
    print(*ans, sep="\n")

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

K = int(input())
total = 0
 
def gcd(a, b):
    if(a > b):
        a, b = b, a
 
    while(b > 0):
        r = a % b
        a = b
        b = r
 
    return a
 
 
for a in range(1, K+1):
    for b in range(1, K+1):
        res = gcd(a, b)
        for c in range(1, K+1):
           total += gcd(res, c)
 
 
print(total)

### FIXED CODE ###

K = int(input())
total = 0

def gcd(a, b):
    if(a > b):
        a, b = b, a

    while(b > 0):
        r = a % b
        a = b
        b = r

    return a

dp = [[0 for i in range(K+1)] for j in range(K+1)]

for a in range(1, K+1):
    for b in range(1, K+1):
        if(dp[a][b] == 0):
            dp[a][b] = gcd(a, b)

        res = dp[a][b]

        for c in range(1, K+1):
            if(dp[res][c] == 0):
                dp[res][c] = gcd(res, c)

            total += dp[res][c]


print(total)
### BUGGY CODE ###

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

a_set = set(a)
total = 0
cnt = 0

for i in a_set:
    cnt = a.count(i)
    total += cnt*(cnt-1)//2

tmp = 0
for i in a:
    tmp = a.count(i) - 1
    print(total - tmp)

### FIXED CODE ###

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

a_dict = {}

for i in a:
    if i in a_dict:
        a_dict[i] += 1
    else:
        a_dict[i] = 1

total_com = 0
for i in a_dict.values():
    total_com += i*(i-1)//2

tmp = 0
for i in a:
    tmp = a_dict[i] - 1
    print(total_com - tmp)
### BUGGY CODE ###

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

for i in range(m):
    a.sort()
    a.reverse()
    m -= 1
    a[0] = a[0] // 2

print(sum(a))


### FIXED CODE ###

import heapq

n,m = map(int, input().split())
#a = list(map(int, input().split()))
a = [-int(n) for n in input().split()]

heapq.heapify(a)

for i in range(m):
    tmp = heapq.heappop(a)
    tmp = int(tmp/2)
    heapq.heappush(a,tmp)

print(-sum(a))

"""
for i in range(m):
    a.sort()
    a.reverse()
    m -= 1
    a[0] = a[0] // 2

print(sum(a))
"""
"""
def heapsort(iterable):
    h = []
    for value in iterable:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(len(h))]
"""
### BUGGY CODE ###

s=input()
count=0
while(True):

	if not 'W' in s or not 'B' in s :
		print(count)
		break

	if s[0]=='W':
		point=s.find('B')
		for i in range(point):
			s=s[:i]+'B'+s[i+1:]
	elif s[0]=='B':
		point=s.find('W')
		for i in range(point):
			s=s[:i]+'W'+s[i+1:]

	count+=1

### FIXED CODE ###

s=input()
count=0
for i in range(0,len(s)-1):
	if s[i]!=s[i+1]:
		count+=1
print(count)
### BUGGY CODE ###

N = int(input())
T = [{} for i in range(N+1)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    T[a][b] = c
    T[b][a] = c

Q, K = map(int, input().split())
shortest_path = [0 for _ in range(N+1)]
queue = [[v, T[K][v], K] for v in T[K].keys()]

for _ in range(N-1):
    v = queue.pop(0)
    shortest_path[v[0]] = v[1]
    queue += [[u, T[v[0]][u] + v[1], v[0]] for u in T[v[0]].keys() if u != v[2]]

for _ in range(Q):
    x, y = map(int, input().split())
    print(shortest_path[x] + shortest_path[y])

### FIXED CODE ###

from collections import deque

N = int(input())
T = [{} for i in range(N+1)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    T[a][b] = c
    T[b][a] = c

Q, K = map(int, input().split())
shortest_path = [0 for _ in range(N+1)]
queue = deque([[v, T[K][v], K] for v in T[K].keys()])
for _ in range(N-1):
    v = queue.popleft()
    shortest_path[v[0]] = v[1]
    queue.extend([[u, T[v[0]][u] + v[1], v[0]] for u in T[v[0]].keys() if u != v[2]])

for _ in range(Q):
    x, y = map(int, input().split())
    print(shortest_path[x] + shortest_path[y])
### BUGGY CODE ###

# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    idx = [0] * N
    d = 0
    while True:
        c = [False] * N
        for i in range(N):
            if idx[i] >= N - 1: continue
            if c[i]: continue
            m = A[i][idx[i]]
            if A[m][idx[m]] == i:
                c[i] = True
                c[m] = True
        f = False
        for i in range(N):
            if c[i]:
                idx[i] += 1
                f = True
        if not f:
            print(-1)
            return
        d += 1
        if all([idx[i] >= N - 1 for i in range(N)]):
            print(d)
            return

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    A = [list(map(lambda x:int(x) - 1, input().split())) for _ in range(N)]
    main(N, A)


### FIXED CODE ###

N = int(input())
A = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]

indices = [0] * N
def next(i):
    return A[i][indices[i]] if indices[i] < N-1 else -1

from collections import deque
q = deque()
for i in range(N):
    j = next(i)
    if i < j and next(j) == i:
        q.append((i, j))

m = N*(N-1)//2
days = 0
while q:
    days += 1
    nq = deque()
    while q:
        i, j = q.pop()
        m -= 1
        indices[i] += 1
        indices[j] += 1
        ni = next(i)
        nj = next(j)
        if ni >= 0 and next(ni) == i:
            nq.append((i, ni))
        if nj >= 0 and nj != i and next(nj) == j:
            nq.append((j, nj))
    q = nq

if m > 0:
    print(-1)
else:
    print(days)
### BUGGY CODE ###

s=input()
c=0
while True:
    t=s.replace('01','').replace('10','')
    r=len(s)-len(t)
    if r==0:
        break
    else:
        c+=r
        s=t
print(c)

### FIXED CODE ###

from collections import Counter
s=input()
if len(set(s))==1:
    print(0)
else:
    c=Counter(s).most_common()
    print(c[1][1]*2)