Harryxun/stf_run huggingface dataset:
long = int(input())
p = input()
plng = []
pstr = p.split(" ")
n = 0

for i in range(long):
    plng.append(int(pstr[i]))

print(plng)

for i in range(long-2):
    three = [plng[i],plng[i+1],plng[i+2]]
    three.sort()

    if three[1] == plng[i + 1]:
     n = n +　1

print(n)


### FIXED CODE ###

long = int(input())
p = input()
plng = []
pstr = p.split(" ")
n = 0

for i in range(long):
    plng.append(int(pstr[i]))



for i in range(long-2):
    three = [plng[i],plng[i+1],plng[i+2]]
    three.sort()

    if three[1] == plng[i + 1]:
     n = n + 1

print(n)
str = raw_input()

for a in list(str):
    if a.islower():
        print a.upper()
    elif a.isupper():
        print a.lower()
    else
        print a

### FIXED CODE ###

str = raw_input()
li = []
for a in list(str):
    if a.islower():
        li.append(a.upper())
    elif a.isupper():
        li.append(a.lower())
    else:
        li.append(a)
print "".join(li)
n = int(input())
a = []
a = input().split()
b = 1
for num in range(n):
  b = b * a[num]
if b > 10**18:
  b = -1
print(b)

### FIXED CODE ###

N = int(input())
A = map(int, input().split())
 
res = 1
 
for a in sorted(A):
    res *= a
    if res > 10 ** 18:
        print("-1")
        exit()
print(res)
f, s = input().split()
if f>9 and s>9:
  print(-1)
else:
  print(f*s)

### FIXED CODE ###

s = input()
if len(s) > 3:
  print(-1)
else:
  print(eval(s.replace(" ", "*")))
i = 0
while True :
  x = int(input())
    if(x == 0) :
       break
    else :
      i += 1
      print("Case", i, ":", x)
    


### FIXED CODE ###

i = 0

while True :
    x = int(input())
    if x == 0 :
        break
    else :
        i += 1
        print("Case ", i, ": ", x, sep = "")
n = int(input)
for i in range(n):
    t,x,y = map(int, input(),split())
    if x+y>t or (x+y+t)%2 :
    	print("No")
    	break
print("Yes")

### FIXED CODE ###

n = int(input())
for i in range(n):
    t,x,y = map(int, input().split())
    if x+y>t or (x+y+t)%2 :
    	print("No")
    	exit()
print("Yes")
n, m = map(int, input().split())
ans = ['0'] * n
for i in range(m):
    s, c = map(int,input().split())
    if s == 1 and c == 0 and n != 1:
        print(-1)
        break
    if ans[s-1] != '0' and c != ans[s-1]:
        print(-1)
        break
    ans[s-1] = c
else:
    if n == 1 and int(ans[0]) == 0:
        print(0)
        break
    elif ans[0] == '0':
        ans[0] = '1'
    ans = map(str, ans)
    print(''.join(ans))

### FIXED CODE ###

n, m = map(int, input().split())
ans = ['0'] * n
for i in range(m):
    s, c = map(int,input().split())
    if s == 1 and c == 0 and n != 1:
        print(-1)
        break
    if ans[s-1] != '0' and c != ans[s-1]:
        print(-1)
        break
    ans[s-1] = c
else:
    if n == 1 and int(ans[0]) == 0:
        print(0)
        exit()
    elif ans[0] == '0':
        ans[0] = '1'
    ans = map(str, ans)
    print(''.join(ans))
l = list(map(int, input().split()))
l.sort()
for i in l:
    if i == len(l)-1:
        print(i)
    else:
        print(i+" ")

### FIXED CODE ###

l = list(map(int, input().split()))
l.sort()
for i in range(len(l)):
    if i == len(l)-1:
        print(l[i])
    else:
        print(l[i], end = " ")
import sys

def main():
    N = int(sys.stdin.readline())
    a = list(map(int, input().split()))
    n = [0 for i in range(0, max(a)+1)]
    for i in a:
        n[i] += 1
    print(max([i+j+k for i, j, k in zip(n, n[1:], n[2:])]))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

def main():
    N = int(sys.stdin.readline())
    a = list(map(int, input().split()))
    n = [0 for i in range(0, max(a)+1)]
    for i in a:
        n[i] += 1
    if len(n) < 3:
        print(sum(n))
    else:
        print(max([i+j+k for i, j, k in zip(n[:-2], n[1:-1], n[2:])]))

if __name__ == '__main__':
    main()
data = int(input().split())
S = data[0]*data[1]
L = 2*(data[0]+data[1])
print(int(S, L))

### FIXED CODE ###

a, b = list(map(int, input().split()))  
print(a * b, 2 * (a + b))
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
  
n, k = (int(i) for i in input().split())
total = cmb(n - 1, 2)
flag = True

if total < k:
    print(-1)
    flag = False

dif = total - k

print(n - 1 + dif)
for i in range(n - 1):
    print(1, i + 2)
    
p = 2
c = 3
while True:
    if dif == 0:
        break
        
    if c > n:
        p += 1
        c = p + 1
        print(p, c)
        c += 1
    else:
        print(p, c)
        c += 1
        
    dif -= 1

### FIXED CODE ###

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, k = (int(i) for i in input().split())

if n == 2:
    if k == 0:
        print(1)
        print(1, 2)
    else:
        print(-1)
else:
    total = cmb(n - 1, 2)
    
    if total < k:
        print(-1)
    else:
        dif = total - k

        print(n - 1 + dif)
        for i in range(n - 1):
            print(1, i + 2)

        p = 2
        c = 3
        while True:
            if dif == 0:
                break

            if c > n:
                p += 1
                c = p + 1
                print(p, c)
                c += 1
            else:
                print(p, c)
                c += 1

            dif -= 1
a = input(),b = input()

print(6-a-b)

### FIXED CODE ###

a = int(input())
b = int(input())

print(6-a-b)
,m=map(int,input().split())
if n==m:
  print('Yes')
else:
  print('No'

### FIXED CODE ###

n,m=map(int,input().split())
if n==m:
  print('Yes')
else:
  print('No')
N = int(input())
A = [0] + list(map(int, input().split()))

for i in range(N-1, 0, -1):
    tmp = 0
    for t in range(i, N+1, i):
        tmp += A[t]
    if tmp == i:
        break

print(tmp)
for i in range(1, tmp+1):
    if i % tmp == 0:
        print(i)


### FIXED CODE ###

N = int(input())
A = [0] + list(map(int, input().split()))

for i in range(N//2, 0, -1):
    # tmp = 0
    # j = i
    # while j < N+1:
    #     tmp += A[j]
    #     j += j
    # A[i] = tmp % 2
    A[i] = sum(A[i::i]) % 2
ans = [i for i, j in enumerate(A) if j == 1]

print(len(ans))
print(*ans)
r = input()
r = int(r)

print(r ** 2 * 3.14)
print(r * 2 * 3.14)

### FIXED CODE ###

import math
r = input()
r = float(r)
s = r ** 2 * 3.141592653589793
enshu = r * 2 * 3.141592653589793
print("{0:.6f}".format(s))
print("{0:.6f}".format(enshu))
A,B,C,K=map(int,input().split())
if (A>=K):
  print(K)
else:
  D = K-A
  if (B>=D):
    print(A)
  else:
    D = D-B
    print(A-D)

### FIXED CODE ###

S=input()
T=input()
if (S==T[:len(T)-1]):
  print("Yes")
else:
  print("No")
if s == 'ABC':
    print('ARC')
else:
    print('ABC')

### FIXED CODE ###

s = input()
if s == 'ABC':
    print('ARC')
else:
    print('ABC')
n,q = map(int,input().split())
s = input()
m = [list(map(int,input().split())) for i in range(q)]
count = [0]*(N+1)
 
for i in range(n):
    if S[i:i+2] == 'AC':
        comu[i+1] = comu[i] + 1
    else:
        comu[i+1] = comu[i]
 
for l,r in list:
    print(count[r-1]-count[l-1])

### FIXED CODE ###

s = input()
p = s.replace('A','B')
q = p.replace('T','A')
r = q.replace('B','T')
w = r.replace('G','W')
x = w.replace('C','G')
y = x.replace('W','C')
print(y)
a = map(int, input().split())
print(max(a)-min(a))

### FIXED CODE ###

a = list(map(int, input().split()))
print(max(a)-min(a))
s = map(str,input().split())
ans = 0
if s[1]=='+':
  ans = int(s[0])+int(s[2])
else:
  ans = int(s[0])-int(s[2])
print(ans)

### FIXED CODE ###

s = list(map(str,input().split()))
ans = 0
if s[1]=='+':
  ans = int(s[0])+int(s[2])
else:
  ans = int(s[0])-int(s[2])
print(ans)
s=input()
t=input()

count = []

for i in range(len(s)-len(t)):
    c=0
    for j in range(i,i+len(t)):
        if s[j] == t[j]:
            c+=1
    
    count.append(c)

print(len(t)-max(count))


### FIXED CODE ###

s=input()
t=input()

count = []

for i in range(len(s)-len(t)+1):
    c=0
    for j in range(i,i+len(t)):
        if s[j] == t[j-i]:
            c+=1
    count.append(c)

# print(count)
print(len(t)-max(count))
import re
s=input()

def hoge(str):
    if(str == ""):
    	return "YES"
	if(str.startWith("dream".sort(reverse=True))):
		return hoge(re.sub('^maerd', '', str))
	if(str.startWith("dreamer".sort(reverse=True))):
		return hoge(re.sub('^remerd' '', str))
	if(str.startWith("erase".sort(reverse=True))):
		return hoge(re.sub('^esare', '', str))
	if(str.startWith("eraser".sort(reverse=True))):
		return hoge(re.sub('^resare', '', str))
	return "NO"

print(s.sort(reverse=True))

### FIXED CODE ###

def main():
    S = input()

    while len(S) >= 5:
        if len(S) >= 7 and S[-7:] == "dreamer":
            S = S[:-7]
            continue

        if len(S) >= 6 and S[-6:] == "eraser":
            S = S[:-6]
            continue

        elif S[-5:] == "dream" or S[-5:] == "erase":
            S = S[:-5]
            continue

        else:
            break

    if len(S) == 0:
        print("YES")
    else:
        print("NO")

main()
def solve():
    from sys import stdin
    #f_i = stdin
    f_i = open('ABC_145_E_in_s4')#
    
    N, T = map(int, f_i.readline().split())
    AB = [tuple(map(int, f_i.readline().split())) for i in range(N)]
    AB.sort()
    
    dp = [[0] * T for i in range(N + 1)]
    
    for i, AB_i in enumerate(AB, start=1):
        A_i, B_i = AB_i
        dp_i = dp[i]
        dp_pre = dp[i-1]
        for j, t in enumerate(zip(dp_pre[A_i:], dp_pre), start=A_i):
            x, y = t
            if x < y + B_i:
                dp_i[j] = y + B_i
            else:
                dp_i[j] = x
    
    ans = max(dp[k][-1] + AB[k][1] for k in range(N))
    ans = max(ans, dp[-1][-1])
    print(ans)

solve()

### FIXED CODE ###

def solve():
    from sys import stdin
    f_i = stdin
    
    N, T = map(int, f_i.readline().split())
    AB = [tuple(map(int, f_i.readline().split())) for i in range(N)]
    AB.sort()
    
    dp = [[0] * T for i in range(N + 1)]
    
    for i, AB_i in enumerate(AB, start=1):
        A_i, B_i = AB_i
        dp_i = dp[i]
        dp_pre = dp[i-1]
        dp_i[:A_i] = dp_pre[:A_i]
        for j, t in enumerate(zip(dp_pre[A_i:], dp_pre), start=A_i):
            x, y = t
            if x < y + B_i:
                dp_i[j] = y + B_i
            else:
                dp_i[j] = x
    
    ans = max(dp[k][-1] + AB[k][1] for k in range(N))
    print(ans)

solve()
n,k=list(map(int,input().split()))
arr=list(map(int,input().split()))
vis=[False for i in range(n)]
a=[]
start=curr=0
vis[0]=True
a.append(start)
for i in range(k):
    curr=a[-1]
    if vis[arr[curr-1]-1]:
        a.append(arr[curr-1] - 1)
        break
    else:
        vis[arr[curr-1]-1]=True
        a.append(arr[curr-1]-1)
#now i have req cycle
if 3>5 and a[0]==a[-1]:
    a.pop()
    #print("helo")
    #print(len(a),a)
    print(a[k%(len(a))]+1)
else:
    count=0
    #print(a,"a")
    for i in range(len(a)):
        if a[i]==a[-1]:
            new=a[i:-1]
            #print(new,a[i:-1])
            break
        else:
            count+=1
    #print(len(new),new)
    #rint(count,"c")
    print(new[(k-count)%(len(new))]+1)


### FIXED CODE ###

s=input()
t=input()
if s==t[:-1]:
    print("Yes")
else:
    print("No")
s = int(input())
a = set(s)
p = s
n = 0
cnt = 0
while True:
  if n in a:
    print(cnt)
    exit()
  if p&1:
    n = 3*p +1
  else:
    n = p//2
  cnt += 1
  set.add(n)
  p = n


### FIXED CODE ###

s = int(input())
a = set([s])
p = s
n = 0
cnt = 1
while True:
  if n in a:
    print(cnt)
    exit()
  a.add(n)
  if p&1:
    n = 3*p +1
  else:
    n = p//2
  cnt += 1
  p = n
n = int(input())
x = 0
for i in range(n) :
  list[] = int(input())

while True :
    for j in range(n):
        if list[j] % 2 == 1:
            break
    
    for k in range(n):
        list[k] = list[k] / 2

    x = x + 1
   
print(x)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
s = 0

def count(A, n):
    for i in range(n):
        if (A[i] % 2 == 1) or (A[i] == 0):
            return False
        A[i] = A[i] // 2
    return True

while True:
    if count(A, n):
        s += 1
    else:
        break
    
print(s)
x,y,a,b,c = (int(x) for x in input().split())

from bisect import insort

p_list = []
q_list = []
r_list = []

for value in input().split():
  value = int(value)
  if len(p_list) >= x:
    if p_list[x-1] < value:
      insort(p_list,value)
      p_list = p_list[:x+1]
  else:
    insort(p_list,value)

for value in input().split():
  value = int(value)
  if len(q_list) >= y:
    if q_list[y-1] < value:
      insort(q_list,value)
      q_list = q_list[:y+1]
  else:
    insort(q_list,value)
  
for value in input().split():
  value = int(value)
  if len(r_list) >= x+y:
    if r_list[x+y-1] < value:
      insort(r_list.value)
      r_list = r_list[:x+y+1]
  else:
    insort(r_list,value)
  
red = 0
green = 0
white = 0

sum_num = 0

for i in range(1,x+y+1):
  if red < x:
  	red_num = p_list[(red*-1)-1]
  else:
    red_num = 0
  if green < y:
  	green_num = q_list[(green*-1)-1]
  else:
    green_num = 0
  if white < c:
  	white_num = r_list[(white*-1)-1]
  else:
    white_num = 0
  
  max_p = max([red_num,green_num,white_num])
  sum_num += max_p
  if max_p == white_num:
    white += 1
  elif max_p == red_num:
    red += 1
  elif max_p == green_num:
    green += 1

print(sum_num)

### FIXED CODE ###

x,y,a,b,c = (int(x) for x in input().split())

from bisect import insort

p_list = list(map(int,input().split()))
q_list = list(map(int,input().split()))
r_list = list(map(int,input().split()))


p_list.sort()
q_list.sort()
r_list.sort()

red = 0
green = 0
white = 0

sum_num = 0

for i in range(1,x+y+1):
  if red < x:
  	red_num = p_list[(red*-1)-1]
  else:
    red_num = 0
  if green < y:
  	green_num = q_list[(green*-1)-1]
  else:
    green_num = 0
  if white < c:
  	white_num = r_list[(white*-1)-1]
  else:
    white_num = 0
  
  max_p = max([red_num,green_num,white_num])
  sum_num += max_p
  if max_p == white_num:
    white += 1
  elif max_p == red_num:
    red += 1
  elif max_p == green_num:
    green += 1

print(sum_num)
import heapq
N,K = map(int,input().split())
td = [list(map(int,input().split())) for i in range(N)]
td.sort(key = lambda x:-x[1])
sumn = [[] for i in range(N)]
for i in range(N):
    heapq.heapify(sumn[i])
ans = 0
kind = {}
for t,d in td[:K]:
    if t not in kind:
        kind[t] = 1
    else:
        kind[t] += 1
    heapq.heappush(sumn[t-1],d)
kinds = len(kind)
ans = sum(sum(i) for i in sumn)
ans1 = ans +kinds**2
rem = td[K:]
nex = 0
candel = []
heapq.heapify(candel)
for k,v in kind.items():
    for i in range(v-1):
        candel.append(heapq.heappop(sumn[k-1]))
qd = heapq.heappop(candel)
while K+nex < N:
    if td[K+nex][0] not in kind:
        kind[td[K+nex][0]] = 1
        kinds += 1
        ans = ans - qd + td[K+nex][1]
        ans1 = max(ans1,ans+kinds**2)
        nex += 1
        if candel:
            qd = heapq.heappop(candel)
        else:
            break
    else:
        nex += 1
print(ans1)

### FIXED CODE ###

import heapq
N,K = map(int,input().split())
td = [list(map(int,input().split())) for i in range(N)]
td.sort(key = lambda x:-x[1])
sumn = [[] for i in range(N)]
for i in range(N):
    heapq.heapify(sumn[i])
ans = 0
kind = {}
for t,d in td[:K]:
    if t not in kind:
        kind[t] = 1
    else:
        kind[t] += 1
    heapq.heappush(sumn[t-1],d)
kinds = len(kind)
ans = sum(sum(i) for i in sumn)
ans1 = ans +kinds**2
rem = td[K:]
nex = 0
candel = []
heapq.heapify(candel)
for k,v in kind.items():
    for i in range(v-1):
        heapq.heappush(candel,heapq.heappop(sumn[k-1]))
if candel:
    qd = heapq.heappop(candel)
    while K+nex < N:
        if td[K+nex][0] not in kind:
            kind[td[K+nex][0]] = 1
            kinds += 1
            ans = ans - qd + td[K+nex][1]
            ans1 = max(ans1,ans+kinds**2)
            nex += 1
            if candel:
                qd = heapq.heappop(candel)
            else:
                break
        else:
            nex += 1
print(ans1)
A =int( input())
B =int( input())
C =int( input())
D = int(input())
E = int(input())

li = [A,B,C,D,E]
li_nonzero=[]

for x in li:
    if x % 10 != 0:
        li_nonzero.append(x)

z = li_nonzero[0]%10
for y in li_nonzero:
    if y % 10 <= z:
        z = y%10
        last_menu = y
        
li.remove(last_menu)

if len(li) > 4:
    while(len(li)==4):
        li.append(last_menu)
sum_time = 0
for menu in li:
    if menu % 10 != 0:
        sum_time = sum_time +( (menu//10)*10+10)
    else:
        sum_time = sum_time +( (menu//10)*10+0)
        
    
print(sum_time+last_menu)
    

### FIXED CODE ###

A =int( input())
B =int( input())
C =int( input())
D = int(input())
E = int(input())

li = [A,B,C,D,E]
li_nonzero=[]



for x in li:
    if x % 10 != 0:
        li_nonzero.append(x)

if len(li_nonzero) == 0:
    last_menu = li[4]
    li.remove(li[4])
else:
    z = li_nonzero[0]%10
    for y in li_nonzero:
        if y % 10 <= z:
            z = y%10
            last_menu = y
            
    li.remove(last_menu)

if len(li) < 4:
    while(len(li)==4):
        li.append(last_menu)
sum_time = 0
for menu in li:
    if menu % 10 != 0:
        sum_time = sum_time +( (menu//10)*10+10)
    else:
        sum_time = sum_time +( (menu//10)*10+0)
        
    
print(sum_time+last_menu)
N = int(input())
a = list(map(int,input().split()))
count = 0

if N != 2:
    for i in range(1,N):
        if a[i] == a[i-1]:
            a[i] = a[i+1] + 1
            count = count + 1
else:
    if a[0] == a[1]:
        count = count + 1


print(count)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
count = 0

if N != 2:
    for i in range(1,N-1):
        if a[i] == a[i-1]:
            a[i] = a[i+1] + 1
            count = count + 1
else:
    if a[0] == a[1]:
        a[0] = a[1]+1
        count = count + 1

if a[N-2] == a[N-1]:
    count = count + 1

print(count)
S=str(input())
L=['SUN','MON','TUE','WED','THU','FRI','SAT']
s=L.index(L)

print(7-s)



### FIXED CODE ###

S=str(input())
L=['SUN','MON','TUE','WED','THU','FRI','SAT']
s=L.index(S)

print(7-s)
import math
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
x.reverse()

j=a+1
moto=0
h=0
d=x[a-1]
asd=0
l=x.count(d)
for i in range(a):
  moto+=x[i]
  if x[i]==x[a-1]:
    h+=1
print(moto/a)
if x[0]==x[a-1]:
  for i in range(a,b+1):
    asd+=math.factorial(l)//(math.factorial(l-i)*math.factorial(i))
  print(asd)
else:
  print(math.factorial(l)//(math.factorial(l-h)*math.factorial(h)))   

### FIXED CODE ###

import math
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
x.reverse()

j=a+1
moto=0
h=0
d=x[a-1]
asd=0
l=x.count(d)
for i in range(a):
  moto+=x[i]
  if x[i]==x[a-1]:
    h+=1
print(moto/a)
if moto/a==x[a-1]:
  for i in range(a,b+1):
    if l-i>=0:
      asd+=math.factorial(l)//(math.factorial(l-i)*math.factorial(i))
  print(asd)
else:
  print(math.factorial(l)//(math.factorial(l-h)*math.factorial(h)))
#small, large or equal

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

if a<b:
	print('a < b')
elif a>b:
	print('a > b')
else:
	print('a = b')

### FIXED CODE ###

import math

r = float(float(input())) #??´??°??§?????????????????\???????????¨??? int?????????????????????????????????

#menseki
a = r*r*math.pi
 
#ensyu
b = 2*r*math.pi

print("%.6f %.6f" % (a, b))
def candy():
    n = input().split()
    N = int(n[0])
    x = int(n[1])
    alist = [int(i) for i in input().split()]

    s = 0
    for i in range(0, N - 1):
        c = alist[i] , d = alist[i + 1]
        if int( alist[i] + alist[i + 1] ) > x:
            if int( alist[i] ) >= x:
                alist[i] = x
                alist[i + 1] = 0
            else :
                alist[i + 1] = x - a[i] 
            s += c - alist[i] + d - alist[i + 1]
        /*  
        if int(alist[i]) > x:
            s = s + int(alist[i+1])
            alist[i+1] = 0

        if int(alist[i+1]) + int(alist[i]) > x:
            s = s + (int(alist[i+1]) + int(alist[i]) - x)
            alist[i+1] = x - int(alist[i])
        */
    print(s)
candy()

### FIXED CODE ###

def candy():
    n = []
    n = input().split()
    N = int(n[0])
    x = int(n[1])
    alist = [int(i) for i in input().split()]

    s = 0
    for i in range(0, N - 1):
        c = int(alist[i])
        d = int(alist[i + 1])
        if int( alist[i] + alist[i + 1] ) > x:
            if int( alist[i] ) >= x:
                alist[i] = x
                alist[i + 1] = 0
            else :
                alist[i + 1] = int(x - alist[i] )
            s += c - int(alist[i]) + d - int(alist[i + 1])
        """
        if int(alist[i]) > x:
            s = s + int(alist[i+1])
            alist[i+1] = 0

        if int(alist[i+1]) + int(alist[i]) > x:
            s = s + (int(alist[i+1]) + int(alist[i]) - x)
            alist[i+1] = x - int(alist[i])
        """
    print(s)
candy()
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, K = map(int, input().split())
        S = input().rstrip()

        b = []
        before = S[0]
        cnt = 1
        for i in range(1, N):
            if before == S[i]:
                cnt += 1
                if i == N - 1:
                    b.append(cnt)
            else:
                b.append(cnt)
                cnt = 1
                before = S[i]

        for _ in range(K):
            target = None
            tmp = 0
            if len(b) == 1:
                break
            if len(b) == 2:
                b = [sum(b)]
                break
            for i in range(1, len(b) - 1):
                current = b[i - 1] + b[i] + b[i + 1]
                if current > tmp:
                    tmp = current
                    target = i
            b = b[:target - 1] + [tmp] + b[target + 2:]

        print(sum(b) - len(b))


# Run main
if __name__ == '__main__':
    AtCoder().main()

### FIXED CODE ###

# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, K = map(int, input().split())
        S = input().rstrip()

        score = 0
        for i in range(N - 1):
            if S[i] == S[i + 1]:
                score += 1
        print(min(N - 1, score + 2 * K))
            

# Run main
if __name__ == '__main__':
    AtCoder().main()
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
	(s, r) = input.().split()
	cards[s][int(r) - 1] = 1

for s in ('S', 'H', 'C', 'D',):
	for r in range(13):
		if cards [s] [r] == 0:
			print(s, r + 1)

### FIXED CODE ###

cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1
    
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)
A, B, C, D = map(int, input().split())

rad = 2 * math.pi * (((C / 12)+((5 / 60)*(D / 60))) - (D /60))

if math.cos(rad) == 1:
    print(abs(A - B))
elif math.cos(rad) == -1:
    print(A + B)
else:
    print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(rad)))

### FIXED CODE ###

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

rad = 2 * math.pi * (((C / 12)+((5 / 60)*(D / 60))) - (D /60))

if math.cos(rad) == 1:
    print(abs(A - B))
elif math.cos(rad) == -1:
    print(A + B)
else:
    print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(rad)))
import sys

a = int(sys.argv[1])
b = int(sys.argv[2])
c = int(sys.argv[3])

if b-a is c-b:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

import sys

x = sys.stdin.readline().strip().split(" ")

if int(x[1])-int(x[0]) == int(x[2])-int(x[1]):
    print("YES")
else:
    print("NO")