Harryxun/stf_run huggingface dataset:
def try_dfs_fill_distance(graph, cur_node, cur_dist_from_origin, distance_cache):
    found_conflicts = False
    for neighbor_node_data in graph[cur_node]:
        neighbor_node, neighbor_distance_from_cur = neighbor_node_data
        neighbot_dist_from_origin = (cur_dist_from_origin + neighbor_distance_from_cur)
        if distance_cache[neighbor_node] == None:
            distance_cache[neighbor_node] = neighbot_dist_from_origin
            try_dfs_fill_distance(graph, neighbor_node, neighbot_dist_from_origin, distance_cache)
        else:
            if distance_cache[neighbor_node] != neighbot_dist_from_origin:
                found_conflicts = True
                break

    return found_conflicts

if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    graph = [[] for _ in range(n + 1)]
    for _ in range(m):
        l, r, d = list(map(int, input().split()))
        graph[l].append((r, d))
        graph[r].append((l, -d))

    distance_cache = [None for _ in range(n + 1)]
    has_conflict = False
    for i in range(1, len(distance_cache)):
        if distance_cache[i] == None:
            distance_cache[i] = 0
            has_conflict = try_dfs_fill_distance(graph, i, 0, distance_cache)
            if not has_conflict:
                break

    print("No" if has_conflict else "Yes")


### FIXED CODE ###

import sys
sys.setrecursionlimit(200002)

def try_dfs_fill_distance(graph, cur_node, cur_dist_from_origin, distance_cache):
    found_conflicts = False
    for neighbor_node_data in graph[cur_node]:
        neighbor_node, neighbor_distance_from_cur = neighbor_node_data
        neighbor_dist_from_origin = (cur_dist_from_origin + neighbor_distance_from_cur)
        #print("cur_node:{} neighbor_node:{} neighbor_dist:{} origin to {}:{}".format(cur_node, neighbor_node, neighbor_distance_from_cur, neighbor_node, neighbor_dist_from_origin))
        if distance_cache[neighbor_node] == None:
            distance_cache[neighbor_node] = neighbor_dist_from_origin
            found_conflicts = try_dfs_fill_distance(graph, neighbor_node, neighbor_dist_from_origin, distance_cache)
        else:
            if distance_cache[neighbor_node] != neighbor_dist_from_origin:
                #print("{} {} {}".format((distance_cache[neighbor_node] == None), distance_cache[neighbor_node], neighbor_dist_from_origin))
                found_conflicts = True

        if found_conflicts:
            break

    return found_conflicts

if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    graph = [[] for _ in range(n + 1)]
    for _ in range(m):
        l, r, d = list(map(int, input().split()))
        graph[l].append((r, d))
        graph[r].append((l, -d))

    distance_cache = [None for _ in range(n + 1)]
    has_conflict = False
    for i in range(1, len(distance_cache)):
        if distance_cache[i] == None:
            distance_cache[i] = 0
            has_conflict = try_dfs_fill_distance(graph, i, 0, distance_cache)
            if has_conflict:
                break

    print("No" if has_conflict else "Yes")
L, R , d= int(input().split())

counter=0
for i in range(R-L):
  num = i+L
  if num%d:
    counter+=1
print(counter)

### FIXED CODE ###


L, R ,d= map(int,input().split())
counter=0
for i in range(R+1-L):
  num = i+L
  if num%d == 0:
    counter+=1
print(counter)
n, k = map(int,input().split())
p = list(input())
a = []
ape = 1
for i in range(1,n):
     if p[i-1] != p[i]:
          a.append(ape)
          ape = 1
     else:
          ape += 1
a.append(ape)

if (p[0] == '1') or (len(a) == 1):
     kaisi = 0
else:
     kaisi = 1

ans = 0
anslist = []

for i in range(kaisi,min(2*k+1+kaisi,len(a))):
     ans += a[i]
anslist.append(ans)

for i in range(kaisi+2,len(a),2):
     if i+2*k <= len(a)-1:
          ans = ans-a[i-2]-a[i-1]+a[i+2*k]+a[i+2*k-1]
          anslist.append(ans)
     else:
          break
ans = 0
if (kaisi != 0) and (k != 0):
     for i in range(0,2*k):
          ans += a[i]
     anslist.append(ans)

print(max(anslist))
     

### FIXED CODE ###

#参考　https://atcoder.jp/contests/abc124/submissions/4948803
from itertools import accumulate

n, k = map(int,input().split())
p = list(input())
a = []
pre = '1'
cnt = 0
for i in range(n):
     if pre != p[i]:
          a.append(cnt)
          cnt = 1
          pre = p[i]
     else:
          cnt += 1
a.append(cnt)
if pre == '0':
     a.append(0)

w = 2*k+1

if w >= len(a):
     print(n)
else:
     acc = list(accumulate(a))
     ans = 0
     acc = [0] + acc
     for i in range(0,len(a)-w+1,2):
          ans = max(ans,acc[i+w]-acc[i])
     print(ans)
a,b = (int(i) for i in input().split())

length = b - a
count = length - 1

for j in range(length):
  a -= count
  print(a)
  if a =< 0:
    print(1 - a)
    break
  else:
    count -= 1
    print(count)

### FIXED CODE ###

a,b = (int(i) for i in input().split())

length = b - a
result = 0

for j in range(length):
  result += j
  
print(result + length - b)
n=int(input())
h=list(map(int,input(),split()))
a=0
for i in range(1,n):
    if h[i]>h[i-1]:
        a+=1
    else :
        a=0
print(a)


### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
a=0
max=0
for i in range(1,n):
    if h[i]<=h[i-1]:
        a+=1
        if i==n-1 and a>max:
            max=a
    elif a>max:
        max=a
        a=0
    else:
        a=0
print(max)
from math import factorial


def comb(n, r):
    if n == 0 or n-r < 0:
        return 0
    return factorial(n) / factorial(r) / factorial(n-r)


N = int(input())
S = []
for i in range(N):
    s = list(input())
    s.sort()
    S.append(s)

S.sort()

count = 0
count_min = 0
tmp = []
for s in S:
    if s == tmp:
        count_min += 1
    else:
        count += comb(count_min+1, 2)
        count_min = 0
    tmp = s
    # print('count:{}, min:{}'.format(count, count_min))
count += comb(count_min+1, 2)
print(int(count))


### FIXED CODE ###

import unittest
from io import StringIO
import sys
from math import factorial
from scipy.misc import comb
import math


def resolve():
    N = int(input())
    d = {}
    count = 0
    for i in range(N):
        s = list(input())
        s.sort()
        s = ''.join(s)
        if s not in d.keys():
            d[s] = 1
        else:
            count += d[s]
            d[s] += 1

    print(count)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
acornistnt
peanutbomb
constraint"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
oneplustwo
ninemodsix"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa"""
        output = """4"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()
# -*- coding:utf-8 -*-

import sys

w = int(input())
n = int(input())

array = []
count = 0
for i in sys.stdin:
    array.append(i)
    count += 1
    if count == n:
        break

a, b = [0]*n, [0]*n
for i in range(n):
    s = array[i]
    a[i], b[i] = s[0], s[2]
    a[i], b[i] = int(a[i]), int(b[i])

lines = []
k = 0
for i in range(w):
    lines.append(k)
    k += 1 

for i in range(n):
    tmp1 = lines[a[i]-1]
    tmp2 = lines[b[i]-1]
    lines[a[i]-1] = tmp2
    lines[b[i]-1] = tmp1

for i in range(len(lines)):
    print(lines[i]+1)

### FIXED CODE ###

# -*- coding: utf-8 -*-
 
import sys
 
def amida(w, side_bar):
    result = []
    side_bar.reverse()
    for x in range(1, w+1):
        status = x
        for bar in side_bar:
            if status == bar[0]:
                status = bar[1]
            elif status == bar[1]:
                status = bar[0]
        result.append(status)
    return result
 
def main():
    W = int(input())
    N = int(input())
    side_bar = [tuple(map(int, input().split(','))) for line in range(N)]
    result = amida(W, side_bar)
    for r in result:
        print(r)
 
if __name__ == '__main__':
    main()
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a;
  cin >> a;
  cout << 48-a << endl;
}


### FIXED CODE ###

M = int(input())
print(48-M)
N,R = map(int,input().split())

if N<10:
  print(100*(10-K))
else:
  print(R)

### FIXED CODE ###

N,R = map(int,input().split())
 
if N<10:
  print(R+100*(10-N))
else:
  print(R)
import collections
n,x,y=map(int,input().split())
import heapq


class Dijkstra:

    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) != 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        if self.goal_point is not None:
            return self.get_path(self.goal_point, prev)
        else:
            return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal

        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]

        return list(reversed(path))

route_map = [dict() for _ in range(n)]
route_map[x-1][y-1]=1
route_map[y-1][x-1]=1
for i in range(n-1):
    route_map[i][i+1] = 1
    route_map[i+1][i]=1    
lst=[]
for i in range(n):
    lst+=Dijkstra(route_map,i).execute()        
Lst=list(collections.Counter(lst).items())
Key=list(collections.Counter(lst).keys())
m=max(Key)
for i in range(1,m+1):
    print(Lst[i][1]//2)
for i in range(m+1,n):
    print(0)


### FIXED CODE ###

import collections
n,x,y=map(int,input().split())
lst=[]
num=[0]*(n+1)
for i in range(1,n):
  for j in range(i+1,n+1):
    k=min(abs(i-j),abs(i-x)+1+abs(j-y),abs(i-y)+1+abs(j-x))
    if num[k]==0:
      num[k]+=1
    lst.append(k)
    
Lst=list(collections.Counter(lst).items())
key=0
for i in range(1,n):
  if num[i]==0:
    print(0)
  else:
    print(Lst[key][1])
    key+=1
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

data = [0] * 100000

def my_sum(d):
    retval = 0

    for i in range(len(d)):
        if d[i] == 0:
            continue
        retval += d[i] * i
    return retval

for i in A:
    data[i] += 1
 
for i in range(Q):
    B, C = map(int, input().split())

    if data[B] != 0:
        data[C] += data[B]
        data[B] = 0
 
    print(my_sum(data))

### FIXED CODE ###

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

data = [0] * 100001

def my_sum(d):
    retval = 0

    for i in range(len(d)):
        if d[i] == 0:
            continue
        retval += d[i] * i
    return retval

for i in A:
    data[i] += 1

sum_val = my_sum(data)

for i in range(Q):
    B, C = map(int,input().split())

    sum_val = sum_val - (data[B] * B) + (data[B] * C)

    data[C] += data[B]
    data[B] = 0

    print(sum_val)
n = int(input())

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

s = 0



for i in range(n+1):
    s += abs(a[i+1] - a[i])

for i in range(1,n+1):
    if (a[i] - a[i-1])*(a[i+1] - a[i]) < 0:
        if abs(a[i] - a[i-1]) < abs(a[i+1] - a[i]):
            print(s - 2*abs(a[i] - a[i-1]))
        else:
            print(s - 2*abs(a[i+1] - a[i]))
    else :
        print(s)







### FIXED CODE ###

print(min(int(input()), int(input())) + min(int(input()), int(input())))
n = input()
x = []
for i in range(n):
  s,p=input().split()
  x.append([s,int(p),i+1])
x.sort(key=lambda x:(x[0],-x[1]))
for i in x:
  print(i[2])

### FIXED CODE ###

n = int(input())
x = []
for i in range(n):
  s,p=input().split()
  x.append([s,int(p),i+1])
x.sort(key=lambda x:(x[0],-x[1]))
for i in x:
  print(i[2])
s = input()
if  s[3] == s[4] and s[5] == s[6]:
  print('yes')
else:
  print('no')


### FIXED CODE ###

S = input()
if S[2] == S[3] and S[4] == S[5]:
  print('Yes')
else:
  print('No')
X, Y, A, B, C = map(int, input().split())
P = map(int, input().split())
Q = map(int, input().split())
R = map(int, input().split())

P = sorted(P, reverse=True)[:X]
Q = sorted(Q, reverse=True)[:Y]

L = sorted(P + Q + R, reverse=True)
print(sum(L[:X+Y]))


### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P = sorted(P, reverse=True)[:X]
Q = sorted(Q, reverse=True)[:Y]
R = sorted(R, reverse=True)

L = sorted(P + Q + R, reverse=True)
print(sum(L[:X+Y]))
a, b, c = input().split()
if a[len(a-1)] == b[0] and b[len(b-1)] == c[0]:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

a, b, c = input().split()
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
    print("YES")
else:
    print("NO")
cost_list=list(map(int,input().split())
cost_list.sort(reverse=True)
sum=0
for i in range(len(cost_list)-1):
  sum+=(cost_list[i]-cost_list[i+1])
print(sum)

### FIXED CODE ###

cost_list=list(map(int,input().split()))
cost_list.sort(reverse=True)
sum=0
for i in range(len(cost_list)-1):
  sum+=(cost_list[i]-cost_list[i+1])
print(sum)
import sys
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  print(res)
  sys.exit()
res = 1

for i in range(n):
  if(res > pow(10,18)):
    res = -1
    break
  else:
    res = res * a[i]
print(res)

### FIXED CODE ###

import sys
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  res = 0
  print(res)
  sys.exit()
  
res = 1
for i in range(n):
  if(res > pow(10,18)):
    break
  else:
    res = res * a[i]
if(res > pow(10,18)):
   res = -1
print(res)
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
sorted(p)
sorted(q)
for i in range(X):
    r.append(p.pop())
for i in range(Y):
    r.append(q.pop())
SpiderMan = sorted(r)[::-1]
print(sum(SpiderMan[:X+Y]))


### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
IronMan = sorted(p)
CaptainAmerica = sorted(q)
for i in range(X):
    r.append(IronMan.pop())
for i in range(Y):
    r.append(CaptainAmerica.pop())
SpiderMan = sorted(r)[::-1]
print(sum(SpiderMan[:X+Y]))
A, B, C, D, E, F = map(int, input().split())

W = set()
for a in range(0, F+1, 100 * A):
    for b in range(0, F - a+1, 100 * B):
        W.add(a + b)

S = set()
for c in range(0, F+1, C):
    for d in range(0, F - c+1, D):
        S.add(c + d)

ans = None
mx = 0
for w in W:
    for s in S:
        if 0 < w + s <= F and s <= w * E // 100:
            if mx < s/(w+s):
                ans = w+s, s
                mx = s/(w+s)
print(ans[0], ans[1])


### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())

W = set()
for a in range(0, F+1, 100 * A):
    for b in range(0, F - a+1, 100 * B):
        W.add(a + b)

S = set()
for c in range(0, F+1, C):
    for d in range(0, F - c+1, D):
        S.add(c + d)

mx = -1
for w in W:
    for s in S:
        if 0 < w + s <= F and s <= w * E // 100:
            if mx < s/(w+s):
                ans = w+s, s
                mx = s/(w+s)
print(ans[0], ans[1])
N,M = map(int,input().split())
print("#"*(N+2))
for i in range(M):
    print("#"+str(input())+"#")
print("#"*(N+2))


### FIXED CODE ###

N,M = map(int,input().split())
print("#"*(M+2))
for i in range(N):
    print("#"+str(input())+"#")
print("#"*(M+2))
a,b,c,d=list(map(int, input().split()))
ac=a*c
ad=a*d
bc=b*c
cd=b*d
print(max([ac,ad,bc,bd]))

### FIXED CODE ###

a,b,c,d=list(map(int, input().split()))
ac=a*c
ad=a*d
bc=b*c
bd=b*d
print(max([ac,ad,bc,bd]))
inf = 2019
L, R = map(int, input().split())
ans = 2018
L = L % 2019
R = R % 2019
if L > R:
    print(0)
    sys.exit
for i in range(L, R):
    if i > R:
      break
      
    for j in range(i + 1, R + 1):
        tmp = int((i * j) % inf)
        ans = min(ans, tmp)
        
print(ans)


### FIXED CODE ###

inf = 2019
L, R = map(int, input().split())
ans = 0
df = R - L
if df < 2019:
    L = L % inf
    R = L + df
    ans = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            tmp = int((i * j) % inf)
            ans = min(ans, tmp)

print(ans)
#!/usr/bin/env python3
from math import factorial as f
n, k = map(int, input().split())
mod = 10**9+7
for i in range(k):
    print(f(n - k + 1) * f(k - 1) // f(i + 1) // f(n - k - i) // f(i) // f(k - i - 1) % mod)

### FIXED CODE ###

#!/usr/bin/env python3
from math import factorial as f
n, k = map(int, input().split())
mod = 10**9+7
for i in range(k):
    try:
        print(f(n - k + 1) * f(k - 1) // f(i + 1) // f(n - k - i) // f(i) // f(k - i - 1) % mod)
    except ValueError:
        print(0)
A = int(input())
B = int(input())
C = int(input())
K = int(input())
if A > K:
    print(K)
elif B > K:
    print(A)
else:
    ans = (A*1) + (B*0) + (K-(A+B))*(-1)
    print(ans)

### FIXED CODE ###

A,B,C,K=(int(x) for x in input().split())
remain_A = K-A
if remain_A<=0:
    print(K)
else:
    remain_B = remain_A - B
    if remain_B <= 0:
        print(A)
    else:
        ans = (A*1) + (B*0) + (remain_B * (-1))
        print(ans)
n, m = map(int,input().split())

a = [[] for _ in range(n+1)]

for _ in range(m):
    l, r, d = map(int,input().split())
    a[l].append((r,d))
    a[r].append((l,-d))

x = [float('inf') for _ in range(n+1)]

flag = [True]



def check(start,destination,cost):
    #x[destination] = x[start] + cost
    if x[destination] == float('inf'):
        x[destination] = x[start] + cost
        while a[destination]:
            n_destination, n_cost = a[destination].pop()
            check(destination,n_destination,n_cost)
    else:
        if x[destination] == x[start] + cost:
            while a[destination]:
                n_destination, n_cost = a[destination].pop()
                check(destination,n_destination,n_cost)
        else:
            flag[0] = False

for i in range(1,n+1):
    if a[i]:
        x[i] = 0
        for y in a[i]:
            check(i,y[0],y[1])
    else:
        pass

if flag[0]:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

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

a = [[] for _ in range(n)]

for _ in range(m):
    l, r, d = map(int,input().split())
    a[l-1].append((r-1,d))
    a[r-1].append((l-1,-d))

x = [None for _ in range(n)]

def check(y):
    for z,d in a[y]:
        if x[z] is None:
            x[z] = x[y] + d
            if not check(z):
                return False
        elif x[z] != x[y] + d:
            return False
    return True

for i in range(n):
    if x[i] is None:
        x[i] = 0
        if not check(i):
            print('No')
            exit(0)
print('Yes')
N,K=map(int,input().split())
p=list(map(int,input().split()))
p_=[0]*N
for a in range(N):
    p_[a]=(1+p[a])/2
A=[]          
for i in range(N-K+1):
            A.append(sum(p_[i:i+K]))
print(max(A))


### FIXED CODE ###

s,t=input().split()
a,b=map(int,input().split())
u=input()
if u==s:
  print(a-1,b)
else:
  print(a,b-1)
import math
a,b = map(int,input().split())
def lcm(x,y):
    return (x*y)//math.gcd(x,y)
print(lcm(a,b))

### FIXED CODE ###

import fractions
a,b = map(int,input().split())
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)
print(lcm(a,b))
def d_c(s):
  count = 0
  x = ''
  for i in range(len(s)):
    if x == s[0]:
      count += 1
      x = ''
    else:
      x = s[0]
    s = s[1:]
  return count
 
def num_con(s):
  x = s[0]
  s = s[1:]
  count = 1
  for i in range(len(s)):
    if s[0] == x:
      count += 1
      x = s[0]
      s = s[1:]
    else:
      break
  return count
      
    
s = input()
k = int(input())
 
if len(s)==1:
  print(k//2)
elif num_con(s)==len(s):
  print(d_c(s*k))
elif s[0]==s[-1]:
  f = num_con(s)
  m = num_con(s[::-1])
  dis = (f//2 + m//2 - (f+m)//2)*(k-1)
  print(d_c(s)*k-dis)
else:
  print(d_c(s)*k)

### FIXED CODE ###

def d_c(s):
  count = 0
  x = ''
  for i in range(len(s)):
    if x == s[0]:
      count += 1
      x = ''
    else:
      x = s[0]
    s = s[1:]
  return count
 
def num_con(s):
  x = s[0]
  s = s[1:]
  count = 1
  for i in range(len(s)):
    if s[0] == x:
      count += 1
      x = s[0]
      s = s[1:]
    else:
      break
  return count
      
    
s = input()
k = int(input())
 
if len(s)==1:
  print(k//2)
elif num_con(s)==len(s):
  print((len(s)*k)//2)
elif s[0]==s[-1]:
  f = num_con(s)
  m = num_con(s[::-1])
  dis = (f//2 + m//2 - (f+m)//2)*(k-1)
  print(d_c(s)*k-dis)
else:
  print(d_c(s)*k)
# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 0か1の連続している人数のリスト、累積和
streak = [0, 0]
N, K = lr()
S = sr() + '2'
cur = 1
for i in range(N):
    if S[i] != S[i+1]:
        streak.append(cur)
        cur = 1
    else:
        cur += 1

streak_cum = list(itertools.accumulate(streak))
streak_cum.extend([streak_cum[-1], streak_cum[-1]])
if S[0] == '0':
    start = 0
else:
    start = 1
answer = 0

for i in range(start, len(streak_cum), 2):
    result = streak_cum[i+2*K+1] - streak_cum[i]
    if result > answer:
        answer = result

print(answer)
# 52


### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
S = np.array([int(x) for x in input()] + [2])

blocks = [] # 同じ数の塊
seq = 1
for i in range(N):
    if S[i+1] == S[i]:
        seq += 1
    else:
        blocks.append(seq)
        seq = 1
blocks = np.array(blocks)

answer = blocks[:2*K].sum()

start = 0 if S[0] == 1 else 1
for i in range(start, len(blocks), 2):
    answer = max(answer, blocks[i:i+(2*K+1)].sum())

print(answer)
n,a,b=map(int, input().split())
some=[]
for i in range(1,n+1):
    if a<=sum(map(int, list(str(i))))<=b:
        some.append(i)
print(sum(some))

### FIXED CODE ###

a,b,c,d=map(int, input().split())
print('Balanced' if  a+b==c+d else 'Left' if a+b>c+d else 'Right')
QUE=input("")
    EatSM=0
    Sum=QUE.count("+")
    Minus=QUE.count("-")
    print(EatSM+Sum-Minus)

### FIXED CODE ###

import sys
import io

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(n):
    QUE=n
    EatSM=0
    Sum=QUE.count("+")
    Minus=QUE.count("-")
    return EatSM+Sum-Minus

def readQuestion():
    line = sys.stdin.readline().rstrip()
    return line

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()