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

class UFT():
    def __init__(self):
        self.par = {}
        self.rank = {}

    def find(self, x):
        if self.par.get(x, x) == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        self.rank[x] = self.rank.get(x, 0)
        self.rank[y] = self.rank.get(y, 0)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def root(self, x):
        return self.par.get(x, x)


N, K, L = [int(_) for _ in input().split()]

C = UFT()
for _ in range(K):
    p, q = [int(_) for _ in input().split()]
    C.unite(p, q)
for _ in range(L):
    r, s = [int(_) for _ in input().split()]
    C.unite(r + N, s + N)
memo = [[0] * N for _ in range(N)]
for i in range(1, N + 1):
    memo[C.root(i) - 1][C.root(i + N) - N - 1] += 1
print(' '.join(str(memo[C.root(i) - 1][C.root(i + N) - N - 1]) for i in range(1, N + 1)))


### FIXED CODE ###

class UFT():
    def __init__(self):
        self.par = {}
        self.rank = {}

    def find(self, x):
        if self.par.get(x, x) == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        self.rank[x] = self.rank.get(x, 0)
        self.rank[y] = self.rank.get(y, 0)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

N, K, L = [int(_) for _ in input().split()]

Road = UFT()
for _ in range(K):
    p, q = [int(_) for _ in input().split()]
    Road.unite(p, q)
Railway = UFT()
for _ in range(L):
    r, s = [int(_) for _ in input().split()]
    Railway.unite(r, s)
memo = {}
for i in range(1, N + 1):
    memo[Road.find(i), Railway.find(i)] = memo.get((Road.find(i), Railway.find(i)), 0) + 1
print(' '.join(str(memo[Road.find(i), Railway.find(i)]) for i in range(1, N + 1)))
### BUGGY CODE ###

N = int(input())

modsum = 0
for i in range(N-1):
    modsum += (i + 1) % (i +2)
    
print(modsum)

### FIXED CODE ###


N = int(input())

calc_N =  N-1

if calc_N % 2 == 1:
    O = calc_N // 2
    output = (1+calc_N) * O + O + 1
else :
    O = calc_N // 2
    output = (1+calc_N) * O
    
print(output)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
a.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)
    divisors.sort()
    return divisors
divs = make_divisors(a[0]) #list

divsTF = [0]*len(divs)
for i in range(len(divs)):
    j = [1 if a[_] % divs[i] else 0 for _ in range(n) ]

    if sum(j) <= 1:
        divsTF[i] = 1

ans = 1
for i in range(len(divs)):
    if divsTF[i] == 1:
        ans = max(ans,divs[i])


divs2 = make_divisors(a[1]) #list

divsTF2 = [0]*len(divs2)
for i in range(len(divs2)):
    j = [1 if a[_] % divs2[i] else 0 for _ in range(n) ]

    if sum(j) <= 1:
        divsTF2[i] = 1

aans = 1
for i in range(len(divs2)):
    if divsTF2[i] == 1:
        aans = max(aans,divs2[i])
print(max(aans,ans))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.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)
    divisors.sort()
    return divisors
divs = list(set(make_divisors(a[0])+make_divisors(a[1]))) #list

divsTF = [0]*len(divs)
for i in range(len(divs)):
    j = [1 if a[_] % divs[i] else 0 for _ in range(n) ]

    if sum(j) <= 1:
        divsTF[i] = 1

ans = 1
for i in range(len(divs)):
    if divsTF[i] == 1:
        ans = max(ans,divs[i])
print(ans)
### BUGGY CODE ###

while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)==1:break
        if i%15==0:
            if c!="FizzBuzz":
                L[j]=0
        elif i%5==0:
            if c!="Buzz":
		L[j]=0
	elif i%3==0:
            if c!="Fizz":
                L[j]=0
        elif c<>str(i):
            L[j]=0
        j+=1
        while L[j%m]==0:
            j=(j+1)%m
        j%=m
    print " ".join([str(i) for i in L if i!=0])

### FIXED CODE ###

def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)>1:
            if Judge(i)!=c:
                del L[j]
                j%=len(L)
            else:
                j=(j+1)%len(L)
    print " ".join(map(str,L))
### BUGGY CODE ###

import itertools

n, m, x = map(int, input().split())
a = []
for i in range(n):
    tmp = list(map(int, input().split()))
    a.append(tmp)
a2 = list(itertools.permutations(a))

ans = 10 ** 6
w = [0] * m
for i in a2:
    w = [0] * m
    w_ans = 0
    for j in i:
        w = [x + y for x, y in zip(w, j[1:])]
        w_ans += j[0]

        if all([i >= x for i in w]):
            ans = min(ans, w_ans)
            break

print(-1 if ans == 10**6 else ans)

### FIXED CODE ###

n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]

add = []
for i in range(2**n):
    skill = [0] * (m+1)
    for j in range(n):
        if (i>>j)&1:
            skill = list(map(sum, zip(skill, l[j])))
    if min(skill[1:]) >= x:
        add.append(skill)
if add:
    add.sort()
    print(add[0][0])
else:
    print(-1)
### BUGGY CODE ###

import collections

n,m = map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]

q = collections.deque()
for i in range(m):
    if s[i][0] == 1:
        q.append(s[i][1])

for i in  q:
    if [i,n] in s or [n,i] in s:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")



### FIXED CODE ###

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

s1 = set()
s2 = set()
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        s1.add(b)
    elif b == 1:
        s1.add(a)
    elif a == n:
        s2.add(b)
    elif b == n:
        s2.add(a)

if s1.isdisjoint(s2):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
### BUGGY CODE ###

s = int(input())

for x in range(10**9):
  for y in range(10**9):
    t = s - x*y
    if t <= 0:
      break
    if t - int(t) == 0:
      if t % 2 == 0 and t / 2 <= 10**9:
        if abs(x*y - t) != s:
            continue
        print('{0} {1} {2} {3} {4} {5}'.format(0, 0, x, 2, t//2, y))
        quit()
      else:
        for i in range(1, 10**9, 2):
          if t % i == 0 and t // i <= 10**9:
            if abs(x*y - t) != s:
                continue
            print('{0} {1} {2} {3} {4} {5}'.format(0, 0, x, i, t//i, y))
            quit()

### FIXED CODE ###

s = int(input())

a = s // 10**9 + 1
b = 10**9 - s % 10**9
if a > 10**9:
  a -= 1
  b -= 10**9

assert abs(a * 10**9 - b) == s

print(" ".join(map(str, [0, 0, a, 1, b, 10**9])))
### BUGGY CODE ###


# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline

def slv():
    N, M, L = list(map(int, input().rstrip('\n').split()))
    g = [[sys.maxsize]*(N) for _ in range(N)]
    for i in range(N):
        g[i][i] = 0
    for _ in range(M):
        a, b, c = list(map(int, input().rstrip('\n').split()))
        if c <= L:
            g[a-1][b-1] = c
            g[b-1][a-1] = c
    
    for k in range(N):
        for i in range(N):
            for j in range(N):
                g[i][j] = min(g[i][j], g[i][k] + g[k][j])
    gg = [[sys.maxsize]*(N) for _ in range(N)]
    for u in range(N):
        for v in range(N):
            if g[u][v] <= L:
                gg[u][v] = 1
    
    for k in range(N):
        for i in range(N):
            for j in range(N):
                gg[i][j] = min(gg[i][j], gg[i][k] + gg[k][j])

    Q = int(input())
    for _ in range(Q):
        s, t = list(map(int, input().rstrip('\n').split()))
        c = gg[s-1][t-1]
        if c != sys.maxsize:
            print(c-1)
        else:
            print(-1)



def main():
    slv()
    # N, M, L = read_int_n()
    # ABC = [read_int_n() for _ in range(M)]
    # Q = read_int()
    # ST = [read_int_n() for _ in range(Q)]
    
    # (slv(N, M, L, ABC, Q, ST))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def slove():
    import sys
    input = sys.stdin.readline
    n, m, l = list(map(int, input().rstrip('\n').split()))
    INF = 10 ** 11
    w = [[INF] * n for _ in range(n)]
    wl = [[INF] * n for _ in range(n)]

    for i in range(n):
        w[i][i] = 0

    for i in range(m):
        a, b, c = list(map(int, input().rstrip('\n').split()))
        if c <= l:
            w[a - 1][b - 1] = c
            w[b - 1][a - 1] = c

    for i in range(n):
        for j in range(n):
            for k in range(n):
                w[j][k] = min(w[j][k], w[j][i] + w[i][k])

    for i in range(n):
        for j in range(n):
            if w[i][j] <= l:
                wl[i][j] = 1
    for i in range(n):
        for j in range(n):
            for k in range(n):
                wl[j][k] = min(wl[j][k], wl[j][i] + wl[i][k])

    q = int(input().rstrip('\n'))
    for i in range(q):
        s, t = list(map(int, input().rstrip('\n').split()))
        if wl[s-1][t-1] == INF:
            print(-1)
        else:
            print(wl[s-1][t-1] - 1)


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

#!/usr/bin/env python3

k = int(input())
rs = []
n = 0 

cnt = 0 
while True:
    cnt += 1
    n = (10*n + 7)%k
    if n==0:
        print(cnt)
        exit()

    if n in rs: 
        print(-1)
        exit()

    rs.append(n)


### FIXED CODE ###

#!/usr/bin/env python3

k = int(input())
n = 0 

cnt = 0 
for i in range(k):
    n = (10*n + 7)%k
    if n==0:
        print(i+1)
        exit()

print(-1)
### BUGGY CODE ###


import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

H, W = map(int,input().split())
#A = [list(map(int,input().split())) for _ in range(H)]
A = np.array([list(input()) for _ in range(H)], 'U1')
eq = A == '.'

dp = np.zeros((H+1,W+1), dtype=int)
#np.zeros(W+1, dtype=int)
dp[1][1] = 1

for i in range(H):
    for j in range(W):
        if eq[i][j]:
            dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j]
#            print(i,j,dp[i])
            if i == 0 and j== 0:
                dp[i+1][j+1] = 1
    dp[i+1] %= mod

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

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Jan  6 21:36:22 2019

@author: Yamazaki Kenichi
"""

H,W = map(int,input().split())
a = [input() for i in range(H)]

r =[[0]*W for i in range(H)]
r[0][0]=1


for i in range(1,W):
    if a[0][i]== '.':
        r[0][i] = r[0][i-1]

for j in range(1,H):
    if a[j][0] =='.':
        r[j][0] = r[j-1][0]
            
for j in range(1,H):
    for i in range(1,W):
        if a[j][i] == '.':
            r[j][i] = r[j-1][i]+r[j][i-1]

print(r[H-1][W-1]%1000000007)
### BUGGY CODE ###

k,s = input().split(' ')
k,s = int(k),int(s)


count = 0
for i in range(k+1):
	if i > s:
		break
	for j in range(k+1):
		if i+j > s:
			break
		z = s - (i+j)
		if z <= k and z >= 0:
			count += 1

print(count)

### FIXED CODE ###

k,s = input().split(' ')
k,s = int(k),int(s)


count = 0
for i in range(k+1):
	for j in range(k+1):
		z = s - (i+j)
		if z <= k and z >= 0:
			count += 1
print(count)
### BUGGY CODE ###

a, b, x = [int(x) for x in input().split()]
minimum, maximum = None, None

for i in range(a, b + 1):
    if i % x == 0:
        minimum = i
        break

for i in range(b, a - 1, -1):
    if i % x == 0:
        maximum = i
        break

if minimum != None or maximum != None:
    if minimum != None and maximum != None:
        # 普通の / 除算だと3で割ったときに大きくずれる。
        total = (maximum - minimum) // x + 1
    else:
        total = 1
else:
    total = 0

print(total)


### FIXED CODE ###

def main(a, b, x):
    if x > b:
        return 0
    elif x == b:
        return 1

    minimum, maximum = None, None

    for i in range(a, b + 1):
        if i % x == 0:
            minimum = i
            break

    for i in range(b, a - 1, -1):
        if i % x == 0:
            maximum = i
            break

    if minimum != None or maximum != None:
        if minimum != None and maximum != None:
            # 普通の / 除算だと3で割ったときに大きくずれる。
            return (maximum - minimum) // x + 1
        else:
            return 1
    else:
        return 0


def main_b(a, b, x):
    """解説を読んだ。単純なことだった。
    """
    def count(n):
        if n == -1:
            return 0
        else:
            return n // x + 1

    return count(b) - count(a-1)


if __name__ == "__main__":
    a, b, x = [int(x) for x in input().split()]
    print(main_b(a, b, x))
### BUGGY CODE ###

s=input()

def sigma(n):
  return n*(n+1)//2

total=0
if s[0]=='>':
  cnt=s.find('<')
  if cnt==-1:
    cnt=len(s)
    s=''
  else:
    s=s[cnt:]
  total+=sigma(cnt)
  
flag=True
while flag:
  l=[]
  index1=s.find('>')
  if index1!=-1:
    for i in range(index1):
      l.append(s[i])
    s=s[index1:]
  else:
    l.extend(['<']*len(s))
    s=''
    flag=False
  index2=s.find('<')
  if index2!=-1:
    for i in range(index2):
      l.append(s[i])
    s=s[index2:]
  else:
    l.extend(['>']*len(s))
    s=''
    flag=False
  cnt1=l.count('>')
  cnt2=l.count('<')
  if cnt2<=cnt1:
    total+=sigma(cnt1)+sigma(cnt2-1)
  else:
    total+=sigma(cnt2)+sigma(cnt1-1)

print(total)

### FIXED CODE ###

s=input()

def sigma(n):
  return n*(n+1)//2

total=0
if s[0]=='>':
  cnt=s.find('<')
  if cnt==-1:
    cnt=len(s)
    s=''
  else:
    s=s[cnt:]
  total+=sigma(cnt)
  
flag=True
while flag:
  l=[]
  index1=s.find('>')
  if index1!=-1:
    for i in range(index1):
      l.append(s[i])
    s=s[index1:]
  else:
    l.extend(['<']*len(s))
    s=''
    flag=False
  index2=s.find('<')
  if index2!=-1:
    for i in range(index2):
      l.append(s[i])
    s=s[index2:]
  else:
    l.extend(['>']*len(s))
    s=''
    flag=False
  cnt1=l.count('>')
  cnt2=l.count('<')
  if cnt2<=cnt1:
    total+=sigma(cnt1)+sigma(cnt2-1)
  else:
    total+=sigma(cnt2)+sigma(cnt1-1)

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

import sys
import math
import copy
import queue
input = sys.stdin.readline
def LI(): return [int(x) for x in input().split()]
INF = 10**15
DD = ((1,0),(0,1),(-1,0),(0,-1))

S = input().rstrip()
n = int(input())

a = ['','']
d = 0
for _ in range(n):
    q = list(input().split())
    if q[0] == '1':
        d = 1-d
    else:
        if q[1] == '1':
            a[d] += q[2]
        else:
            a[1-d] += q[2]

if d == 1:
    S = ''.join(reversed(list(S + a[1]))) + a[0]
else:
    S = ''.join(reversed(list(a[0]))) + S + a[1]
print (S)

### FIXED CODE ###

import sys
import math
import copy
import queue
input = sys.stdin.readline
def LI(): return [int(x) for x in input().split()]
INF = 10**15
DD = ((1,0),(0,1),(-1,0),(0,-1))

S = [x for x in input().rstrip()]
n = int(input())

a = [[],[]]
d = 0
for _ in range(n):
    q = list(input().split())
    if q[0] == '1':
        d = 1-d
    else:
        if q[1] == '1':
            a[d].append(q[2])
        else:
            a[1-d].append(q[2])

if d == 1:
    a[1].reverse()
    S.reverse()
    S = ''.join(a[1]) + ''.join(S) + ''.join(a[0])
else:
    a[0].reverse()
    S = ''.join(a[0]) + ''.join(S) + ''.join(a[1])
print (S)
### BUGGY CODE ###

N,W=map(int,input().split())
w=[0]*N
v=[0]*N
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j<w[i]:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])
print(dp[N][W])

### FIXED CODE ###

N,W=map(int,input().split())
w=[0]*N
v=[0]*N
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[0]*(W+1)
for i in range(N):
    j=W
    while j>=w[i]:
        dp[j]=max(dp[j],dp[j-w[i]]+v[i])
        j-=1
print(dp[W])
### BUGGY CODE ###

nb=int(input())
liste = [int(x) for x in input().split()]
nba = int(input())
for loop in range(nba):
  n,r = map(int,input().split())
  for loop in range(len(liste)):
    if liste[loop]==n:
      liste[loop] = r
  print(sum(liste))


### FIXED CODE ###

nb=int(input())
liste = [int(x) for x in input().split()]
liste2= [0]*((10**5)+1)
for loop in range(len(liste)):
  liste2[liste[loop]] +=1
nba = int(input())
somme = sum(liste)
for loop in range(nba):
  n,r = map(int,input().split())
  roger = liste2[n]
  diff = r-n
  somme += diff * roger
  liste2[r] += liste2[n]
  liste2[n] = 0
  print(somme)
### BUGGY CODE ###

n = int(input())
m = list(map(int,input().split()))
for i in range(n):
    if i+1 in m:
        print(m.count(i+1))
    else:
        print(0)


### FIXED CODE ###

n = int(input())
m = list(map(int,input().split()))
a = [0 for i in range(n)]
for i in m:
    a[i-1] += 1
for i in a:
    print(i)
### BUGGY CODE ###

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

result = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                result += 1

print(result)


### FIXED CODE ###

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

result = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if 0 <= z <= k:
            result += 1

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

n = int(input())
data = [i for i in range(1, n)]
print(sum(data))

### FIXED CODE ###

n = int(input())
print(int((n-1)*(1+n-1)//2))
### BUGGY CODE ###

# map(int,input().split())
# int(input())
import math
a,b,c = map(int,input().split())
# if a< b 定まらん
# if a>=b a-1
# cの値による？c <= a-2 のとき.
maxcnt = -99999
if c <= b-1:
	for x in range(c+1):
		cnt = math.floor(a*x/b) - a* math.floor(x/b)
		if cnt > maxcnt:
			maxcnt = cnt
else:
	x = b-1
	maxcnt = math.floor(a*x/b) - a* math.floor(x/b)
print(maxcnt)

### FIXED CODE ###

import math
a,b,c = map(int,input().split())
maxcnt = -99999
if c <= b-1:
	x = c
	cnt = (a*x)//b - a*(x//b)
	if cnt > maxcnt:
		maxcnt = cnt
else:
	x = b-1
	maxcnt = math.floor(a*x/b) - a* math.floor(x/b)
print(maxcnt)
### BUGGY CODE ###

from collections import deque
h,w=map(int,input().split())
maze=[input() for i in range(h)]
visited=[[0]*w for i in range(h)]
cnt,b=0,[]
for i in range(h):
  for j in range(w):
    if maze[i][j]=='#':
      b.append(deque([[i,j]]))
      visited[i][j]=1
    else:
      cnt+=1
ans,c=0,[]
while cnt>0:
    ok=False
    for i in range(len(b)):
      if b[i]:
        while b[i]:
          x,y=b[i].popleft()
          c.append((x,y))
        for l,m in c:
          for j,k in [[0,1],[1,0],[-1,0],[0,-1]]:
            newx,newy=l+j,m+k
            if 0<=newx<h and 0<=newy<w:
              if maze[newx][newy]!='#' and visited[newx][newy]!=1:
                visited[newx][newy]=1
                b[i].append([newx,newy])
                cnt-=1
                ok=True
    if ok:
      ans+=1
print(ans)

### FIXED CODE ###

from collections import deque
def main():
  h,w=map(int,input().split())
  hw=h*w
  maze=[list(input()) for i in range(h)]
  visited=[[hw]*w for i in range(h)]
  ans,q=0,deque()
  for i in range(h):
    for j in range(w):
      if maze[i][j]=='#':
        q.append((i,j))
        visited[i][j]=0
  while q:
    x,y=q.popleft()
    for i,j in ((0,1),(1,0),(-1,0),(0,-1)):
      newx,newy=x+i,y+j
      if 0<=newx<h and 0<=newy<w:
        if maze[newx][newy]!='#' and visited[newx][newy]==hw:
          visited[newx][newy]=visited[x][y]+1
          q.append((newx,newy))
          ans=max(ans,visited[newx][newy])
  return print(ans)
if __name__=='__main__':
  main()
### BUGGY CODE ###

import math

n = int(input())

def N(n, i, j):
    num = 0
    for x in range(1,n+1):
        low = int(x%10)
        high = int(x/(pow(10, int(math.log10(x)))))
        if((high == i)and(low == j)):
            num = num + 1
    return num

s = 0
for i in range(1,10):
    for j in range(1,10):
        s = s + N(n, i, j)*N(n, j, i)

print(s)
        

    







### FIXED CODE ###

import math

n = int(input())

def N(n, i, j):
    num = 0
    for x in range(1,n+1):
        low = int(x%10)
        high = int(x/(pow(10, int(math.log10(x)))))
        if((high == i)and(low == j)):
            num = num + 1
    return num

s = 0
for i in range(1,10):
    s = s + pow(N(n, i, i), 2)

for i in range(2,10):
    for j in range(1,i):
        s = s + 2*N(n, i, j)*N(n, j, i)

print(s)
### BUGGY CODE ###

string = input()

start_length = len(string)

while len(string) > 0:
  if "10" in string:
    string = string.replace("10", "")
  elif "01" in string:
    string = string.replace("01", "")
  else:
    break

print(start_length - len(string))

### FIXED CODE ###

s = input()

start_len = len(s)

num_1 = s.count("1")
num_0 = s.count("0")

end_len = abs(num_1 - num_0)

print(abs(end_len - start_len))
### BUGGY CODE ###

N, K = map(int,input().split())
A = sorted(map(int,input().split()))
start = 0
end = A[-1]
while end - start > 1:
   l = (start + end)/2
   l = int(l)
   count = 0
   for i in range(N):
      q = A[i]/l
      if q == int(q):
         q -= 1
      count += int(q)
   if count <= K:
      end = l
   else:
      start = l
print(end)

### FIXED CODE ###

N, K = map(int,input().split())
A = list(map(int,input().split()))
start = 0
end = 10**9
while end - start > 1:
   l = (start + end)/2
   l = int(l)
   count = 0
   for i in range(N):
      q = A[i]/l
      if q == int(q):
         q -= 1
      count += int(q)
   if count <= K:
      end = l
   else:
      start = l
print(end)