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

import collections
N,C=map(int,raw_input().split())
#print N,C
d = collections.defaultdict(list)
start=float("inf")
end=0
for i in range(N):
	s,t,c=map(int,raw_input().split())
	d[c].append((s,t))
	start=min(start,s)
	end=max(end,t)

#print start,end
#print d
[d[i].sort() for i in d.keys()]
#print d

c = collections.defaultdict(list)

for i in range(start,end):
	#print "# i"
	#print i
	cnt=0
	for j in d:
		for k in d[j]:
			if i>=k[0] and i<=k[1]:
				#print j,"Yes"
				c[i].append(j)
				break;

#print c

max_recs=0
for i in c.values():
	max_recs=max(max_recs,len(i))

print max_recs

	
	

### FIXED CODE ###

import collections
N,C=map(int,raw_input().split())
a=collections.defaultdict(list)

max_t=0
for i in range(N):
	s,t,c=map(int,raw_input().split())
	a[c].append((s,t))
	max_t=max(max_t,t)

[a[i].sort() for i in a.keys()]
#print a
#print max_t

b=collections.defaultdict(list)


for i,j in a.items():
	start=0
	end=0
	for k in j:
		if start==0 and end==0:
			start=k[0]-1
			end=k[1]
			continue
		elif k[0]<=end:
			end=k[1]
		else:
			b[i].append((start,end))
			start=k[0]-1
			end=k[1]
	else:
		b[i].append((start,end))		

#print "# b"
#print b

c=[0 for i in range(max_t+2)]

for i in b.values():
	for j,k in i:
		#print j,1,k+1,-1
		c[j]+=1
		c[k]-=1
#print c

ans=0
sum=0
for i in c:
	sum+=i
	ans=max(ans,sum)

print ans
### BUGGY CODE ###

N = int(input())
S = input()

R = []
G = []
B = []

ans = 0

for i,col in enumerate(S):
    if col == 'R':
        R.append(i)
    elif col == 'G':
        G.append(i)
    else:
        B.append(i)


for r in R:
    for g in G:
        for b in B:
            l = sorted([r,g,b])
            if l[1]-l[0] != l[2]-l[1]:
                ans += 1

print(ans) 


### FIXED CODE ###

N = int(input())
S = input()

R_count = S.count('R')
G_count = S.count('G')
B_count = S.count('B')

ans = R_count * G_count * B_count

for i in range(N-2):
    for d in range(1,N):
        if i+2*d >= N:
            break
        else:
            j = i+d
            k = j+d
            
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1

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

from collections import deque
h, w = map(int, input().split())
A = [input() for _ in range(h)]
dist = [[-1]*w for _ in range(h)]
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
que = deque()
for i in range(h):
  for j in range(w):
    if A[i][j] == "#":
      que.append((i, j))
      dist[i][j] = 0
ans = 0
while que:
  y, x = que.popleft()
  for dy, dx in zip(di, dj):
    ny, nx = y+dy, x+dx
    if ny < 0 or ny >= h or nx < 0 or nx >= w:
      continue
    if dist[ny][nx] != -1:
      continue
    dist[ny][nx] = dist[y][x] + 1
    ans = max(ans, dist[ny][nx])
    que.append((ny, nx))
print(ans)

### FIXED CODE ###

from collections import deque
h, w = map(int, input().split())
A = [input() for _ in range(h)]
dist = [[-1]*w for _ in range(h)]
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
que = deque()
for i in range(h):
  for j in range(w):
    if A[i][j] == "#":
      que.append((i, j))
      dist[i][j] = 0
while que:
  y, x = que.popleft()
  for dy, dx in zip(di, dj):
    ny, nx = y+dy, x+dx
    if ny < 0 or ny >= h or nx < 0 or nx >= w:
      continue
    if dist[ny][nx] != -1:
      continue
    dist[ny][nx] = dist[y][x] + 1
    que.append((ny, nx))
ans = 0
for i in dist:
  ans = max(ans, max(i))
print(ans)
### BUGGY CODE ###

import sys
N=int(input())
d=sorted(list(map(int,input().split())))
ans=0
while len(d)>=3:
  c=d.pop(-1)
  tmp=[]
  for i in range(len(d)-1):
    for j in range(i+1,len(d)):
      if d[i]+d[j]>c:
        ans+=1
print(ans)

### FIXED CODE ###

import sys
import bisect
N=int(input())
d=sorted(list(map(int,input().split())))
ans=0
for i in range(1,len(d)-1):
  for j in range(i+1,len(d)):
    v=(N-j)-(bisect.bisect_left(d,d[-i]-d[-j]+1))
    if v<=0:
      pass
    else:
      ans+=v
print(ans)
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
lmx = 0
for i in range(n):
    tmp = bin(a[i])
    a[i] = tmp[2:]
    a[i] = a[i][::-1]
    lmx = max(lmx, len(tmp)-2)
res = 0
cnt = [[0,0] for _ in range(lmx)]
for i in range(n):
    bi = a[i]
    ln = len(bi)
    for j in range(lmx):
        if j < ln:
            cnt[j][int(bi[j])] += 1
        else:
            cnt[j][0] += 1
for i,bit in enumerate(cnt):
    x,y = bit
    res += x*y*pow(2,i)
    res %= mod
print(res)

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
a.sort()
ln = len(bin(a[-1])) - 2
bit = [defaultdict(int) for i in range(ln)]
res = 0
for i in a:
    tmp = bin(i)
    for _,j in enumerate(tmp[:1:-1]):
        # print(_,j)
        bit[_][j] += 1
# pprint.pprint(bit)
for i,j in enumerate(bit):
    x = j['0']
    y = j['1']
    if x+y < n:
        x = n - y
    # print(i,x,y)
    c = pow(2,i)
    res += x * y * c
    res %= mod
print(res)
### BUGGY CODE ###

(N, M) = (int(i) for i in input().split(' '))
cards = set(range(1,N+1))

for i in range(0,M):
    # gate i can be opened by following card set
    (l, r) = (int(j) for j in input().split(' '))
    #print(cards, set(range(l,r+1)))
    cards = cards.intersection(set(range(l,r+1)))

print(len(cards))
    

### FIXED CODE ###

(N, M) = (int(i) for i in input().split(' '))
(l0,r0) = (1, N)

n = -1
for i in range(0,M):
    # gate i can be opened by following card set
    (l, r) = (int(j) for j in input().split(' '))
    #print(cards, set(range(l,r+1)))
    if l > r0 or r < l0:
        n = 0
        break
    (l0,r0) = (max(l,l0), min(r,r0))

if n == -1:
    n = r0-l0 +1
    
print(n)
### BUGGY CODE ###

def main():
    MOD = 998244353

    N, S = map(int, input().split())
    *A, = map(int, input().split())

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

    for i, x in enumerate(A):
        dp[i + 1][0][0] = dp[i][0][0]
        for s in range(S, -1, -1):
            dp[i + 1][s][1] = (dp[i][s][1] + dp[i][s][0]) % MOD
            dp[i + 1][s][2] = (dp[i][s][2] + dp[i][s][1] + dp[i][s][0]) % MOD

            if s - x >= 0:
                v = dp[i][s - x][1] + dp[i][s - x][0]
                dp[i + 1][s][1] = (dp[i + 1][s][1] + v) % MOD
                dp[i + 1][s][2] = (dp[i + 1][s][2] + v) % MOD

    print(dp[N][S][2])


if __name__ == '__main__':
    main()

#             dp[i + 1][s][0] = (dp[i + 1][s][0] + dp[i][s][0]) % MOD
#             dp[i + 1][s][1] = (dp[i + 1][s][1]
#                                + dp[i][s][1] + (dp[i][s - x][1] if s - x >= 0 else 0)
#                                + dp[i][s][0] + (dp[i][s - x][0] if s - x >= 0 else 0)) % MOD
#             dp[i + 1][s][2] = (dp[i + 1][s][2]
#                                + dp[i][s][2] +
#                                dp[i][s][1] + (dp[i][s - x][1] if s - x >= 0 else 0)
#                                + dp[i][s][0] + (dp[i][s - x][0] if s - x >= 0 else 0)) % MOD


### FIXED CODE ###

# https://atcoder.jp/contests/abc159/submissions/11139734

def main():
    MOD = 998244353

    N, S = map(int, input().split())
    *a, = map(int, input().split())

    dp = [0] * (S + 1)

    ret = 0
    for i, x in enumerate(a):
        dp[0] += 1
        if x > S: continue
        ret = (ret + dp[S - x] * (N - i)) % MOD
        for k in range(S - 1, x - 1, -1):
            dp[k] = (dp[k] + dp[k - x]) % MOD

    print(ret)


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

def main():
    import sys
    input = sys.stdin.readline
    N, K = [int(x) for x in input().strip().split()]
    P = [int(x) for x in input().strip().split()]
    C = [int(x) for x in input().strip().split()]
    ans = [0] * N
    def f(i, cnt):
        f_cnt = [0] * N
        f_score = [0] * N
        cur = i
        ret = -float('inf')
        ret_ = 0
        while cnt:
            # print('  cur = {}, cnt = {}, ret = {}'.format(cur, cnt, ret_))
            if f_cnt[cur] and f_cnt[cur] - cnt <= cnt:
                if ret_ <= f_score[cur]:
                    break
                ret_ += (cnt // (f_cnt[cur] - cnt)) * (ret_ - f_score[cur])
                cnt %= (f_cnt[cur] - cnt)
                ret = max(ret, ret_)
                continue

            f_cnt[cur] = cnt
            f_score[cur] += ret_
            ret_ += C[cur]
            ret = max(ret, ret_)
            cur = P[cur] - 1
            cnt -= 1

        return ret

    for i in range(N):
        # print('i = {}'.format(i))
        ans[i] = f(i, K)
    
    print(max(ans))


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    N, K = [int(x) for x in input().strip().split()]
    P = [int(x)-1 for x in input().strip().split()]
    C = [int(x) for x in input().strip().split()]
    ans = -float('inf')
    f_cnt = [0] * N
    f_score = [0] * N
    for i in range(N):
        if f_cnt[i]:
            continue
        flag = [False] * N
        j = i
        cnt = 0
        score = 0
        while not flag[j]:
            flag[j] = True
            score += C[j]
            cnt += 1
            j = P[j]
        for j in range(N):
            if flag[j]:
                f_cnt[j] = cnt
                f_score[j] = score
    # print(*f_cnt)
    # print(*f_score)

    def f(cur, cnt):
        ret = -float('inf')
        ret_ = 0
        if f_score[cur] >= 0:
            ret_ += f_score[cur] * (cnt // f_cnt[cur] - 1)
            cnt = cnt % f_cnt[cur] + f_cnt[cur]
            ret = ret_
        else:
            cnt = min(cnt, f_cnt[cur])

        while cnt:
            # print('  cur = {}, cnt = {}, ret = {}'.format(cur, cnt, ret_))
            cur = P[cur]
            ret_ += C[cur]
            ret = max(ret, ret_)
            cnt -= 1

        return ret

    for i in range(N):
        # print('i = {}'.format(i))
        ans = max(ans, f(i, K))
    
    print(ans)

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

import numpy as np
n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

p = np.array(p)
ansum = np.array([])
for i  in range(len(p)-k+1):
    pk = (p[i:i+k]+1)/2
    ansum = np.append(ansum, sum(pk))

print(max(ansum))

### FIXED CODE ###

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

p1 = (sum(p[:k]) + k)/2

ansum = [p1]
for i  in range(len(p)-k):
    p1 = p1 - (p[i]+1)/2 + (p[i+k]+1)/2
    ansum.append(p1)

print(max(ansum))
### BUGGY CODE ###

import heapq
N,Q=map(int,input().split())

event_list=[]
for i in range(N):
  S,T,X=map(int,input().split())
  event_list.append((S-X-0.5,1,X))
  event_list.append((T-X-0.5,-1,X))
  
dlist=[]
for i in range(Q):
  D=int(input())
  event_list.append((D,0,X))  
  dlist.append(D)
event_list.sort()
#print(event_list)

answer_dic={}
stop_set=set()
hq=[]
for t,f,x in event_list:
  if f==1:
    stop_set.add(x)
    heapq.heappush(hq,x)
  elif f==-1:
    stop_set.remove(x)
  else:
    if len(stop_set)>0:
      while(True):
        if hq[0] in stop_set:
          answer_dic[t]=hq[0]
          break
        else:
          heapq.heappop(hq)
    else:
      answer_dic[t]=-1
      hq=[]
#print(answer_dic)

for d in dlist:
  print(answer_dic[d])

### FIXED CODE ###

import heapq
import sys
input=sys.stdin.readline
N,Q=map(int,input().split())

event_list=[]
for i in range(N):
  S,T,X=map(int,input().split())
  event_list.append((S-X-0.5,1,X))
  event_list.append((T-X-0.5,-1,X))
  
dlist=[]
for i in range(Q):
  D=int(input())
  event_list.append((D,0,X))  
  dlist.append(D)
event_list.sort()
#print(event_list)

answer_dic={}
stop_set=set()
min_set=float("inf")
for t,f,x in event_list:
  if f==1:
    stop_set.add(x)
    if x<min_set:
      min_set=x
  elif f==-1:
    stop_set.remove(x)
    if x==min_set:
      if len(stop_set)>0:
        min_set=min(stop_set)
      else:
        min_set=float("inf")
  else:
    if len(stop_set)>0:
      answer_dic[t]=min_set
    else:
      answer_dic[t]=-1
#print(answer_dic)

for d in dlist:
  print(answer_dic[d])
### BUGGY CODE ###

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

def main(N, A_list):
    val = 0
    mod = (10 ** 9) + 7
    for i in range(len(A_list)):
        for j in range(i+1, len(A_list), 1):
            val = (val + (A_list[i] * A_list[j])) % mod
    
    print(val)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)

### FIXED CODE ###

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

def main(N, A_list):
    total_list = []
    total = 0
    for i in range(len(A_list)):
        total += A_list[i]
        total_list.append(total)

    num = 0
    for i in range(len(A_list)-1):
        num += A_list[i] * (total_list[len(A_list)-1]-total_list[i])

    val = num % ((10 ** 9) + 7)
    print(val)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)
### BUGGY CODE ###

import sys
from numba import njit

K = int(sys.stdin.readline().rstrip())
S = sys.stdin.readline().rstrip()
M = int(10**9 + 7)

@njit
def fast_pow(a, b, m):
    base = a
    res = 1
    while b:
        if b & 1:
            res = res * base % m
        base = base * base % m
        b //= 2
    return res

@njit
def build_factorial(max_value):
    fact = [1]
    for i in range(1, max_value + 1):
        fact.append(fact[-1] * i % M)

    finv = [fast_pow(fact[-1], M - 2, M)]
    for i in range(max_value, 0, -1):
        finv.append(finv[-1] * i % M)
    finv.reverse()

    return fact, finv

fact, finv = build_factorial(K + len(S) + 10)

def comb(a, b, m):
    return fact[a] * finv[b] % m * finv[a - b] % m

def hcomb(a, b, m):
    return comb(a + b - 1, a - 1, m)

ans = 0
for l in range(0, K + 1):
    ans += pow(26, l, M) * pow(25, K - l, M) % M * hcomb(len(S), K - l, M) % M
    ans %= M
print(ans)

### FIXED CODE ###

K = int(input())
S = input()
M = int(10 ** 9 + 7)

fact = [1]
for i in range(1, K + len(S) + 10):
    fact.append(fact[-1] * i % M)

finv = [pow(fact[-1], M - 2, M)]
for i in range(K + len(S) + 9, 0, -1):
    finv.append(finv[-1] * i % M)
finv.reverse()

def comb(a, b, m):
    return fact[a] * finv[b] % m * finv[a - b] % m

def hcomb(a, b, m):
    return comb(a + b - 1, a - 1, m)

ans = 0
for l in range(0, K + 1):
    ans += pow(26, l, M) * pow(25, K - l, M) % M * hcomb(len(S), K - l, M) % M
    ans %= M
print(ans)
### BUGGY CODE ###

N,Q=map(int,input().split())
S=list(input())
L=[]
R=[]
for i in range(Q):
    l,r=map(int,input().split())
    L.append(l)
    R.append(r)

for h in range(Q):
    count=0
    for k in range(L[h]-1,R[h]-1):
        if S[k]=='A' and S[k+1]=='C':
            count+=1
            continue
        continue
    print(count)
    

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
c=[0]
t=0
for i in range(1,n):
    t+=1 if (s[i-1]=='A' and s[i]=='C') else 0
    c.append(t)
for i in range(q):
    l,r=map(int,input().split())
    print(c[r-1]-c[l-1])
### BUGGY CODE ###

n = int(input())
li = list(map(int,input().split()))
ans = 0

import math
import bisect
import collections
c = collections.Counter(li)
li = list(set(li))
li.sort()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

while len(li)>0:
    ba = li.pop(-1)
    if c[ba]>1:
        continue
    se = set(make_divisors(ba))
    l1_l2_and = set(li) & set(se)
    if len(l1_l2_and)==0:
        ans += 1
print(ans)


### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))
ans = 0
cnt_li = [0]*(10**6+1)

import math
import bisect
import collections
c = collections.Counter(li)
li = list(set(li))
li.sort()

for l in li:
    for x in range(2,10**7):
        if x*l > (10**6):
            break
        else:
            cnt_li[x*l] += 1


while len(li)>0:
    ba = li.pop(-1)
    if c[ba]>1:
        continue
    if cnt_li[ba] == 0:
        ans += 1
print(ans)
### BUGGY CODE ###

from collections import defaultdict, deque
n,m = list(map(int, input().split()))

d = defaultdict(set)

for _ in range(m):
    
    a,b = list(map(int, input().split()))
    d[a].add(b)
    d[b].add(a)
    
   
def dfs(node):
    
    s = set()
    stack = deque([node])
    while stack:
        
        n = stack.popleft()
        s.add(n)
        for i in d[n]:
            if i not in s and i not in visited:
                stack.append(i)
                
    return s
    
visited = set()
ans = 1

for key in list(d.keys()):
    if key not in visited:
        s = dfs(key)
        ans = max(ans, len(s))
        for i in s:
            visited.add(i)


print(ans)
        

### FIXED CODE ###

from collections import defaultdict, deque
n,m = list(map(int, input().split()))

d = defaultdict(set)

for _ in range(m):
    
    a,b = list(map(int, input().split()))
    d[a].add(b)
    d[b].add(a)
    
visited = set()

def dfs(node):
    
    c = 0
    stack = deque([node])
    visited.add(node)
    while stack:
        n = stack.popleft()
        c+=1
        for i in d[n]:
            if  i not in visited:
                visited.add(i)
                stack.append(i)
                
    return c
    

ans = 1

for key in list(d.keys()):
    if key not in visited:

        c = dfs(key)
        ans = max(ans, c)
        


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

N = int(input())


def divisor(M):
    div = set()
    for i in range(1, int(N ** 0.5 + 0.5) + 1):
        if M % i == 0:
            div.add(i)
            div.add(M // i)
    return div


def simu(M, X):
    while M >= X:
        if M % X == 0:
            M //= X
        elif M % X == 1:
            return True
        else:
            M -= X
    return M == 1


A = divisor(N)
B = divisor(N - 1)

# N%K==1となるやつ
ans = len(B) - 1

for a in (A - B):
    if simu(N, a):
        ans += 1

print(ans)

### FIXED CODE ###

N = int(input())


def divisor(M):
    div = set()
    for i in range(1, int(N ** 0.5 + 0.5) + 1):
        if M % i == 0:
            div.add(i)
            div.add(M // i)
    return div


def simu(M, X):
    cnt = 0
    while M >= X:
        if M % X == 0:
            M //= X
        elif M % X == 1:
            return True
        else:
            M -= X
        cnt += 1
        if cnt > 1000:
            return False
    return M == 1


A = divisor(N)
B = divisor(N - 1)

# N%K==1となるやつ
ans = len(B) - 1

for a in (A - B):
    if simu(N, a):
        ans += 1

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

from itertools import combinations

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

n, m = map(int, inpl())
M = []
for i in range(n):
    M.append(list(map(int, inpl())))

cake_sets = combinations(M, m)
ans = -1
for c_set in cake_sets:
    val = 0
    for typ in range(3):#x, y, z
        t_val = 0
        for i in range(m):
            t_val += c_set[i][typ]
        val += abs(t_val)
    ans = max(ans, val)
print(ans)
        

### FIXED CODE ###

from operator import mul
from itertools import product

n, m = map(int, input().split())
arr = []
for i in range(n):
    ##[[x, y, z], ..., [x, y, z]]
    arr.append(list(map(int, input().split())))

ans = 0
for opList in list(product(list((1, -1)), repeat=3)):
    bufArr = []
    for xyz in arr:
        bufArr.append(sum(map(mul, opList, xyz)))
    ans = max(ans, sum(sorted(bufArr, reverse = True)[:m]))

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

from functools import lru_cache


def popcnt(x):
    return bin(x).count("1")


@lru_cache(maxsize=None)
def rec(n):
    if n == 0:
        return 0
    else:
        return rec(n % popcnt(n)) + 1


n = int(input())
arr = input()

for i in range(n):
    x = arr[:i] + str(1 ^ int(arr[i])) + arr[i + 1:]
    print(rec(int(x, 2)))

### FIXED CODE ###

from functools import lru_cache


def popcnt(x):
    return bin(x).count("1")


@lru_cache(maxsize=None)
def rec(n):
    if n == 0:
        return 0
    else:
        return rec(n % popcnt(n)) + 1


ret = [rec(x) for x in range(2 * 10**5 + 1)]


n = int(input())
arr = input()

ALL_ARR = int(arr, 2)

cnt = popcnt(int(arr, 2))
init_big = ALL_ARR % (cnt + 1)
if cnt == 1:
    init_small = 0
else:
    init_small = ALL_ARR % (cnt - 1)


li = [0] * n
for i in range(n):
    if arr[i] == "0":
        li[i] = (init_big + pow(2, n - i - 1, cnt + 1)) % (cnt + 1)
    elif ALL_ARR - (1 << (n - i - 1)) == 0 or cnt - 1 == 0:
        li[i] = "flg"
    else:
        li[i] = (init_small - pow(2, n - i - 1, cnt - 1)) % (cnt - 1)


ans = []

for x in li:
    if x == "flg":
        ans.append(0)
    else:
        ans.append(ret[x] + 1)

print(*ans, sep="\n")
### BUGGY CODE ###

temp=input()
S=list(temp)
counter1=0
counter2=0 
i=0
while True:
    if S[i]=='B' and S[i+1]=='W':
        S[i]='W'
        S[i+1]='B'
        counter1 +=1
    i +=1
    if i ==len(S)-1:
        if counter1==counter2:
            break
        counter2=counter1
        i=0

print(counter1)



### FIXED CODE ###

S=input()
counter=0
result = 0

for i in range(len(S)):
    if S[i]=='B':
        counter+=1
    else:
        result +=counter

print(result)
### BUGGY CODE ###

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)] 

P = [-1] * (N+1)
P[0] = 1
P[1] = 1
flg=False
MOD = 10**9 + 7
for i in range(2, N+1):
    if i in a:
        continue
    if (i-1 not in a) and (i-2 not in a):
        P[i] = (P[i-1] + P[i-2]) % MOD
    elif i-1 not in a:
        P[i] = P[i-1] % MOD
    elif i-2 not in a:
        P[i] = P[i-2] % MOD
    else:
        flg=True
if flg:
    print(0)
else:
    print(P[N] % MOD)

### FIXED CODE ###

N, M = map(int, input().split())
a = set([int(input()) for _ in range(M)] )

P = [-1] * (N+1)
P[0] = 1
P[1] = 1
flg=False
MOD = 10**9 + 7
for i in range(2, N+1):
    if i-1 not in a:
        P[i] = P[i-1]
    if i-2 not in a:
        if P[i] != -1:
            P[i] += P[i-2] % MOD
        else:
            P[i] = P[i-2] % MOD
    if P[i]==-1:
        flg=True
        break
if flg:
    print(0)
else:
    print(P[N] % MOD)
### BUGGY CODE ###

# ナイーブな解法。厳しいデータだとO(K*N), 2^2 x 10^10 でTLEになるはず

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

ptr = 0
buf = [[a for a in an], [0] * len(an)]
#print(an)
for i in range(k):
    ib = buf[ptr]
    buf[ptr ^ 1] = [0] * len(an)
    ob = buf[ptr ^ 1]
    
    for j in range(n):
        s = ib[j]

        lb = max(j - s, 0)
        ub = min(j + s, len(an) - 1)
        for k_ in range(lb, ub + 1):
            ob[k_] += 1
    #print('k =', i + 1)
    #print(ob)
    ptr ^= 1

print(' '.join(map(str, buf[ptr])))


### FIXED CODE ###

import numpy as np
from numba import njit

@njit('i8,i8,i8[::1]', cache=True)
def fn(n, k, a):
    for _ in range(k):
        b = np.zeros(n, dtype=np.int64)
        for i in range(n):
            lb = max(i - a[i], 0)
            ub = min(i + a[i], n - 1)

            b[lb] += 1
            if ub + 1 < n:
                b[ub + 1] -= 1

        a = b.cumsum()
        if np.all(a == n):
            return a
    return a

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a = np.array(a, dtype=np.int64)

b = fn(n, k, a)
print(' '.join(b.astype(str)))
### BUGGY CODE ###

import copy

n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

def delete_list(n,l):
    new_l = l.copy()
    new_l.remove(new_l[n])
    return new_l

for i in range(n):
    print(max(delete_list(i,l)))

### FIXED CODE ###

n = int(input())
l = []

for i in range(n):
    l.append(int(input()))

def has_duplicates(seq):
    return sorted(seq)[len(seq)-1] == sorted(seq)[len(seq)-2]

x = max(l)

if has_duplicates(l):
    for i in l:
        print(x)
else:
    for i in l:
        if i != x:
            print(x)
        else:
            print(sorted(l)[n-2])