Harryxun/stf_run huggingface dataset:
N, K = map(int, input().split())
S = input()

H0 = 0
N_LR = 0
N_RL = 0

if S[0] == 'R' and S[1] == 'R':
    H0 += 1
if S[0] == 'R' and S[1] == 'L':
    N_RL += 1
if S[0] == 'L' and S[1] == 'R':
    N_LR += 1

if S[N-1] == 'L' and S[N-2] == 'L':
    H0 += 1

for i in range(1, N-1):
    if S[i] == 'L' and S[i-1] == 'L' or S[i] == 'R' and S[i+1] == 'R':
        H0 += 1
    if S[i] == 'R' and S[i+1] == 'L':
        N_RL += 1
    if S[i] == 'L' and S[i+1] == 'R':
        N_LR += 1

M = min(N_RL, N_LR, K)
H1 = H0 + 2 * M
K -= M
N_RL -= M
N_LR -= M

result = H1 + min(K, max(N_RL, N_LR))
print(result)


### FIXED CODE ###

N = int(input())
print(N**3)
#!/usr/bin
# -*- coding="utf-8" -*-
 
K = int(input())
N = K + 1
n = [0] * N
n[0] = K**2 + K*2
n = ' '.join(list(map(str, n)))
print(N)
print(n)


### FIXED CODE ###

#!/usr/bin
# -*- coding="utf-8" -*-
 
K = int(input())
if K >= 50:
  N = 50
  a = K % N
  if a == 0:
    n = [K // N + 49] * N
  else:
    n = [K // N + (49 - a)] * N
    for i in range(a):
      n[i] = n[i] + N
elif K == 0:
  N = 2
  n = ["1", "1"]
else:
  N = K + 1
  n = [0] * N
  n[0] = K**2 + K*2
n = ' '.join(list(map(str, n)))
print(N)
print(n)
N, X = map(int, input().split())

m = [input() for _ in range(N)]

ans1 = X

MING = min(m)

for i in range(N):
    ans1 = ans1 - (m[i])

REST = (ans1)//(MING)

print((REST) + (N))

#この時点でのans1は残りの材量gを示している。
#現時点でN個作成できている。
# m[0] の数をans//で答えて　N+これ

### FIXED CODE ###

N, X = map(int, input().split())
m = []
for _ in range(N):
    m.append(int(input()))

SUM = sum(m)
MIN = min(m)


if SUM < X:
    REST = X - (SUM)
    ans = REST//MIN
    print(ans + N)
    
else:
    print(N)
N = int(input())
#maze = [[0] * (N + 10) for _ in range(2)]
maze = [list(map(int, input().split())) for _ in range(2)]

dp = [[0] * N for _ in range(2)]

dp[0][0] = maze[0][0]
for j in range(1, N):
    dp[0][j] = dp[0][j - 1] + maze[0][j]]

dp[1][0] = dp[0][0] + maze[1][0]
for i in range(1, N):
    dp[1][i] = max(dp[0][i] + maze[1][i], dp[1][i - 1] + maze[1][i])

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

### FIXED CODE ###

N = int(input())
#maze = [[0] * (N + 10) for _ in range(2)]
maze = [list(map(int, input().split())) for _ in range(2)]

dp = [[0] * N for _ in range(2)]

dp[0][0] = maze[0][0]
for j in range(1, N):
    dp[0][j] = dp[0][j - 1] + maze[0][j]

dp[1][0] = dp[0][0] + maze[1][0]

for i in range(1, N):
    dp[1][i] = max(dp[0][i] + maze[1][i], dp[1][i - 1] + maze[1][i])

print(dp[1][N - 1])
import sys
    n = [int(i) for i in input().split()]
    a = []
    for i in range(n[1]):
        a.append(int(input()))
     
    a.append(n[0]+1)
    a = sorted(list(set(a)))
     
     
    def k(i):
        ans = 1
        pri = 0
        for idx in range(i):
            tmp = ans
            ans += pri
            pri = tmp
        return ans
     
     
    for i in range(1, len(a)):
        if a[i]-a[i-1] == 1:
            print(0)
            sys.exit()
    j = -1
    ans = 1
    for i in a:
        ii = i-j-2
        ans = ans*k(ii)
        j = i
    if len(a) == 1:
        ans = k(n[0])
    print(ans % 1000000007)

### FIXED CODE ###

import sys
n = [int(i) for i in input().split()]
a = []
for i in range(n[1]):
    a.append(int(input()))

a.append(n[0]+1)
a = sorted(list(set(a)))


def k(i):
    ans = 1
    pri = 0
    for idx in range(i):
        tmp = ans
        ans += pri
        pri = tmp
    return ans


for i in range(1, len(a)):
    if a[i]-a[i-1] == 1:
        print(0)
        sys.exit()
j = -1
ans = 1
for i in a:
    ii = i-j-2
    ans = ans*k(ii)
    j = i
if len(a) == 1:
    ans = k(n[0])
print(ans % 1000000007)
n=int(input())
sum=0
for i in range(n):
  num=int(input())
  sum+=1/num
print(1/sum)

### FIXED CODE ###

n=int(input())
sum=0
l=list(map(int,input().split()))
for i in range(n):
  num=l[i]
  sum+=1/num
print(1/sum)
N = int(input())

a = []
while N % 2 == 0:
  a.append(2)
  N //= 2
f = 3
while f * f <= N:
  if N % f == 0:
    a.append(f)
    N //= f
  else:
    f += 2
if N != 1:
  a.append(N)

A = 1
B = 1
for i in a:
  if(A > B):
    B *= i
  elif(B > A):
    A *= i
  else:
    A *= i
print(A + B - 2)

### FIXED CODE ###

A, B = map(int, input().split())

if(1 <= A <= 9 and 1 <= B <= 9):
  print(A * B)
else:
  print(-1)
a = input()
b = input()
c = input()

print(a[0] + b[1] + c[2])


### FIXED CODE ###

a, b, c = map(int,input().split())
if a + b >= c:
	print('Yes')
else:
	print('No')
S = input().strip()

def check(l):
  for i in range(len(l)-1):
    if l[i] == l[i+1]:
      return False
  return True

# 一番最後だけ分割する
def hoge(l):
  next_stack = []
  for i in range(1, len(l[-1])):
    next_list = l[:-1] + [l[-1][:i], l[-1][i:]]
    if check(next_list):
      next_stack.append(next_list)
  return next_stack
      
stack = [[S]]
max_len = 1
while True:
  if len(stack) == 0:
    break
  now = stack.pop(0)
  if len(now)+len(now[-1])-2 <= max_len:
    continue
  #print('----------')
  #print(now)
  #print(hoge(now))
  max_len = max(max_len, len(now))
  stack += hoge(now)
  
print(max_len)

### FIXED CODE ###

S = input().strip()

prev = ''
now = ''
result = 0
for c in S:
  if len(prev) == 0:
    prev = c
    result += 1
    continue
  now += c
  if prev == now:
    continue
  else:
    prev = now
    now = ''
    result += 1
print(result)
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
x = [(i, xy[i][0]) for i in range(n)]
y = [(i, xy[i][1]) for i in range(n)]

x.sort(key = lambda x:x[1])
y.sort(key = lambda x:x[1])

x_dif = [((x[i][0], x[i+1][0]), abs(x[i+1][1]-x[i][1])) for i in range(n-1)]
y_dif = [((y[i][0], y[i+1][0]), abs(y[i+1][1]-y[i][1])) for i in range(n-1)]

xy_dif = x_dif + y_dif
xy_dif.sort(key = lambda x:x[1])

p = [i for i in range(n)]

def root(x):
  if p[x]==x:
    return x
  p[x] = root(p[x])
  return p[x]

ans = 0
for i in range(2*(n-1)):
  ab, cost = xy_dif[i]
  a, b = ab
  #print(a, b, p[a], p[b], p)
  if root(a)!=root(b):
    p[root(a)] = root(b)
    ans += cost

print(ans)


### FIXED CODE ###

import sys

sys.setrecursionlimit(2147483647)

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
x = [(i, xy[i][0]) for i in range(n)]
y = [(i, xy[i][1]) for i in range(n)]

x.sort(key = lambda x:x[1])
y.sort(key = lambda x:x[1])

x_dif = [((x[i][0], x[i+1][0]), abs(x[i+1][1]-x[i][1])) for i in range(n-1)]
y_dif = [((y[i][0], y[i+1][0]), abs(y[i+1][1]-y[i][1])) for i in range(n-1)]

xy_dif = x_dif + y_dif
xy_dif.sort(key = lambda x:x[1])

p = [-1]*n

def root(x):
  if p[x]<0:
    return x
  p[x] = root(p[x])
  return p[x]

ans = 0
for ab, cost in xy_dif:
  a, b = ab
  #print(a, b, p[a], p[b], p)
  if root(a)!=root(b):
    p[root(a)] = root(b)
    ans += cost

print(ans)
from itertools import accumulate
from bisect import bisect
N = int(input())
A = list(map(int,input().split()))
C = [0]+list(accumulate(A))

def helper(i,j):
  m = (C[j]+C[i])/2
  k = bisect(C, m, lo=i,hi=j)
  if k == i:
    k += 1
  elif k == j:
    k -= 1

  if k > 0:
    _,a,b = min((abs(m-C[x]),C[x]-C[i],C[j]-C[x]) for x in (k-1,k))
  else:
    a,b = C[k]-C[i],C[j]-C[k]

  return a,b

best = float('inf')

for i in range(2,N-1):
  L = (*helper(0,i),*helper(i,N))
  best = min(best,max(L)-min(L))

print(best)

### FIXED CODE ###

from itertools import accumulate
from bisect import bisect

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

def h(i,j):
  ci,cj = C[i],C[j]
  k = bisect(C, (ci+cj)//2, lo=i+1,hi=j)
  _,a,b = min((abs(ci+cj-2*c),cj-c,c-ci) for c in (C[k-1],C[k]))
  return a,b

def solve(x):
  L = h(0,x)+h(x,N)
  return max(L)-min(L)

print(min(solve(i) for i in range(2,N-1)))
from functools import reduce
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


N = int(input())
A = set(map(int, input().split()))
A = sorted(A)

ans = 1
for i in range(1, A[1]+1):
    if len(list(filter(lambda x: x % i != 0, A))) <= 1:
        ans *= i
print(ans)


### FIXED CODE ###

# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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

for i in range(N):
    L[i+1] = gcd(L[i], A[i])

for i in reversed(range(N)):
    R[i] = gcd(R[i+1], A[i])

ans = max([gcd(x, y) for x, y in zip(L, R[1:])])
print(ans)
import math
n=int(input())
k=2
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    mini=math.inf
    for j in range(i+1,min(n,i+k+1)):
        x=abs(a[j]-a[i])+b[j]
        mini=min(mini,x)
    b[i]=mini
print(b[0])

### FIXED CODE ###

n=int(input())
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    b[i]=min(abs(a[i]-a[i+1])+b[i+1],abs(a[i]-a[i+2])+b[i+2])
print(b[0])
h,w,k=map(int,input().split())
#a(h,x)
p=[-1]*w
p[0]=1
p[1]=2
def pat(x):
    if x<0 or x>=w:
        return 1
    else:
        if p[x]!=-1:
            return p[x]
        else:
            return pat(x-2)+pat(x-1)
        
for j in range(1):
    0
mo=10**9 +7

a=[[0 for i in range(w)] for i in range(h+1)]
a[0]=[1]+[0]*(w-1)
for i in range(1,h+1):
    #a[i][0]=a[i-1][0]*pat(-1)*pat(h-1)+a[i-1][1]*pat(0)*pat(h-2)
    #a[i][w-1]=a[i-1][w-2]*pat(w-3)*pat(h-w+1)+a[i-1][w-1]*pat(w-1-1)*pat(h-w)
    for j in range(0,w):
        if j>0: a[i][j]+=a[i-1][j-1]*pat(j-2)*pat(w-j-2)
        a[i][j]+=a[i-1][j]*pat(j-1)*pat(w-1-j-1)
        if j<w-1: a[i][j]+=a[i-1][j+1]*pat(j-1)*pat(w-j-3)
print(a[h][k-1] % mo)
#print(a)


### FIXED CODE ###

h,w,k=map(int,input().split())
#a(h,x)
p=[-1]*(w+1)
p[0]=1
p[1]=2
def pat(x):
    if x<0 or x>=w:
        return 1
    else:
        if p[x]!=-1:
            return p[x]
        else:
            return pat(x-2)+pat(x-1)
        
for j in range(1):
    0
mo=10**9 +7

a=[[0 for i in range(w)] for i in range(h+1)]
a[0]=[1]+[0]*(w-1)
for i in range(1,h+1):
    #a[i][0]=a[i-1][0]*pat(-1)*pat(h-1)+a[i-1][1]*pat(0)*pat(h-2)
    #a[i][w-1]=a[i-1][w-2]*pat(w-3)*pat(h-w+1)+a[i-1][w-1]*pat(w-1-1)*pat(h-w)
    for j in range(0,w):
        if j>0: a[i][j]+=a[i-1][j-1]*pat(j-2)*pat(w-j-2)
        a[i][j]+=a[i-1][j]*pat(j-1)*pat(w-1-j-1)
        if j<w-1: a[i][j]+=a[i-1][j+1]*pat(j-1)*pat(w-j-3)
print(a[h][k-1] % mo)
#print(a)
L = []

for i in range(3):
	L.append(input())

    
c=0
ans=0

for i in range(3):
	if L[i] == 'R':
      if c !=0:
        ans = 1
      else:
      	ans += 1
    if L[i] == 'S':
      c += 1
      
print(ans)
      	

### FIXED CODE ###



L = []
L.append(input())

if L[0] == 'SSS':
	print(0)
elif L[0] == 'RRR':
	print(3)
elif L[0] == 'SSR' or L[0] == 'SRS':
	print(1)
elif L[0] =='RSS':
	print(1)
elif L[0] == 'SRR' or L[0] == 'RRS':
	print(2)
elif L[0] == 'RSR':
	print(1)
N = input()
L = map(int,raw_input().split())
if max(L) >= (sum(L)-max(L)):
  print "No"
else:
  print "Yes"

### FIXED CODE ###

N = int(input())
l = list(map(int, input().split()))
if 2 * max(l) < sum(l):
  print("Yes")
else:
  print("No")
from math import gcd


def lcm(a, b):
    return abs(a*b) // gcd(a, b)


def main():
    n = int(input())
    ts = [int(input()) for _ in range(n)]
    res = ts[0]
    for t in ts[1:]:
        res = lcm(res, t)
    print(res)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return abs(a * b) // gcd(a, b)


def main():
    n = int(input())
    ts = [int(input()) for _ in range(n)]
    res = ts[0]
    for t in ts[1:]:
        res = lcm(res, t)
    print(res)


if __name__ == '__main__':
    main()
def main():
    import math
    import sys
    input = sys.stdin.readline
    n = int(input())
    mod = 10**9+7
    l1 = []
    l2 = []
    l3 = []
    for i in range(n):
        a,b = map(int,input().split())
        g = math.gcd(a,b)
        a //= g
        b //= g
        
        s2 = [a,b]
        if s2 in l1:
            l3[l1.index(s2)] += 1
        else:
            l1.append(s2)
            l2.append(-1)
            l3.append(1)
            if [-b,a] in l1:
                ind = l1.index([-b,a])
                l2[-1] = ind
                l2[ind] = len(l1)-1
            elif [b,-a] in l1:
                ind = l1.index([b,-a])
                l2[-1] = ind
                l2[ind] = len(l1)-1

    done = set()
    ans = 1
    for i in range(len(l2)):
        if l2[i] < 0:
            ans *= 2
            ans %= mod
        else:
            if l2[i] in done:
                continue
            c1 = l3[i]
            c2 = l3[l2[i]]
            count = (pow(2,c1,mod)+pow(2,c2,mod)-1)%mod
            ans *= count
            ans %= mod
            done.add(i)
            done.add(l2[i])

    print(ans-1)
if __name__ == "__main__":
    main()              


### FIXED CODE ###

import math

n = int(input())
mod = 10**9+7
d = {}

zero = 0
for i in range(n):
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        zero += 1
    else:
        g = math.gcd(a,b)
        a //= g
        b //= g
        if b < 0:
            a = -a
            b = -b
        if b == 0 and a == -1:
            a = 1
        if a > 0:
            if (a,b) in d:
                d[(a,b)][0] += 1
            else:
                d[(a,b)] = [1,0]
        else:
            if (b,-a) in d:
                d[(b,-a)][1] += 1
            else:
                d[(b,-a)] = [0,1]
ans = 1
for (a,b),(c,d) in d.items():
    count = (pow(2,c,mod)+pow(2,d,mod)-1)%mod
    ans *= count
    ans %= mod


print((ans+zero-1)%mod)
# D
N, W = map(int, input().split())
 
import numpy as np

dp = np.zeros((N+1, W+1))

for i in range(1, N+1):
    w, v = map(int, input().split())
    dp[w:W+1] = np.maximum(dp[0:W-w+1]+v[w:W+1], dp[w:W+1])

    print(dp[-1])


### FIXED CODE ###

# D
N, W = map(int, input().split())

import numpy as np
dp = np.zeros(W+1, dtype="int64")

for i in range(1, N+1):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[0:W-w+1] + v)

print(dp[-1])
import sys
n = int(sys.stdin.readline())
p =list(map(int, sys.stdin.readline().split()))
cnt = 0
for i in range(n):
    if min(p[:i+1]) == p[i]:
        cnt+=1
print(cnt)

### FIXED CODE ###

n,m = map(int, input().split())
if n==m:
    print('Yes')
else:
    print('No')
n = int(input())
if 1=<n<=81:
    if n%10==0:
        print('Yes' if n==10 else 'No')
    else:
        print('Yes')

else:
    print('No')

### FIXED CODE ###

l=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, 28, 30, 32, 35, 36, 40, 42, 45, 48, 49, 54, 56, 63, 64, 72, 81]
print('Yes' if int(input()) in l else 'No')
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=0
cnt=1
for j in range(0,N+1):
    D=D+L[j]
    if D>X:
        break
    cnt+=1
print(cnt)

### FIXED CODE ###

N,X=map(int,input().split())
L=list(map(int,input().split()))
D=0
cnt=1
for i in L:
    D=D+i
    if D>X:
        break
    cnt+=1
print(cnt)
S = input()
T = input()

result = 0
for i in range(0,3):
    if S[i] == T[i]:
        result += 1

print (result)

### FIXED CODE ###

A , B = map ( int , input ( )  . split( ) )
 
if ( A<= 9 and B <= 9) :
    print ( A * B )
else:
    print ( -1 )
a, b = input().split()
a1, b1 = list(map(int, input().split()))

print(str(a1) + " " + str(b1 - 1) if input() == b else str(a1 - 1) + " " + b1)

### FIXED CODE ###

a, b = input().split()
a1, b1 = list(map(int, input().split()))

print(str(a1) + " " + str(b1 - 1) if input() == b else str(a1 - 1) + " " + str(b1))
n = int(input())
a = list(map(int,input().split()))

new = 1
if 0 in a:
	print(0)
	exit()
	
for i in a:
	
	new *= a
	if new > (10**18):
		new = -1
		break
print(new)		
	


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
new = 1
if 0 in a:
	print(0)
	exit()
for i in a:
	new *= i
	if new > (10**18):
		new = -1
		break
print(new)
w,h,x,y=map(int,input().split())
ans1=(w*h)/2
ans=0
if (w/2==x)and(h/2==y):
    ans2=1
print('%f %d'%(ans1,ans2))

### FIXED CODE ###

w,h,x,y=map(int,input().split())
ans1=(w*h)/2.0
ans2=0
if (w/2==x)and(h/2==y):
    ans2=1
print('%f %d'%(ans1,ans2))
print(180*(int(input())-2)

### FIXED CODE ###

print(180*(int(input())-2))
# Fast IO (be careful about bytestring)

# import os,io
# input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline


H,W,M = map(int,input().split())
targetList = []
rowCount = [0] * H
columnCount = [0] * W
for _ in range(M):
    p,q = map(int,input().split())
    targetList.append((p-1,q-1))
    rowCount[p-1] += 1
    columnCount[q-1] += 1
rowCountLabelled = []
columnCountLabelled = []
for i in range(H):
    rowCountLabelled.append((rowCount[i],i))
for i in range(W):
    columnCountLabelled.append((columnCount[i],i))
rowCountLabelled.sort(reverse = True)
columnCountLabelled.sort(reverse = True)
targetList.sort()
maxi = rowCountLabelled[0][0] + columnCountLabelled[0][0]
isMaxAchievable = False
for elem1 in rowCountLabelled:
    if elem1[0] != rowCountLabelled[0][0]:
        break
    for elem2 in columnCountLabelled:
        if elem2[0] != columnCountLabelled[0][0]:
            break
        target = (elem1[1],elem2[1])
        l = 0
        r = len(targetList)
        while l < r:
            m = (l + r) // 2
            if target == targetList[m]:
                l = m
                r = m
                break
            elif target < targetList[m]:
                r = m-1
            elif target > targetList[m]:
                l = m + 1
        if (l >= len(targetList) or target != targetList[l]) and target != targetList[r]:
            isMaxAchievable = True
            break
    if isMaxAchievable:
        break
if isMaxAchievable:
    print(maxi)
else:
    print(maxi - 1)


### FIXED CODE ###

# Fast IO (be careful about bytestring)

# import os,io
# input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline


H,W,M = map(int,input().split())
targetList = []
rowCount = [0] * H
columnCount = [0] * W
for _ in range(M):
    p,q = map(int,input().split())
    targetList.append((p-1,q-1))
    rowCount[p-1] += 1
    columnCount[q-1] += 1
rowCountLabelled = []
columnCountLabelled = []
for i in range(H):
    rowCountLabelled.append((rowCount[i],i))
for i in range(W):
    columnCountLabelled.append((columnCount[i],i))
rowCountLabelled.sort(reverse = True)
columnCountLabelled.sort(reverse = True)
targetList.sort()
maxi = rowCountLabelled[0][0] + columnCountLabelled[0][0]
isMaxAchievable = False
for elem1 in rowCountLabelled:
    if elem1[0] != rowCountLabelled[0][0]:
        break
    for elem2 in columnCountLabelled:
        if elem2[0] != columnCountLabelled[0][0]:
            break
        target = (elem1[1],elem2[1])
        l = 0
        r = len(targetList) - 1
        while l < r:
            m = (l + r) // 2
            if target == targetList[m]:
                l = m
                r = m
                break
            elif target < targetList[m]:
                r = m-1
            elif target > targetList[m]:
                l = m + 1
        if (l >= len(targetList) or target != targetList[l]) and target != targetList[r]:
            isMaxAchievable = True
            break
    if isMaxAchievable:
        break
if isMaxAchievable:
    print(maxi)
else:
    print(maxi - 1)
h,n=map(int, input().split())
aList=list(map(int, input().split()))
result = h
for a in aList:
  result -= a
return 'Yes' if result <= 0 else 'No'

### FIXED CODE ###

h,n=map(int, input().split())
aList=list(map(int, input().split()))
result = h
for a in aList:
  result -= a
print('Yes') if result <= 0 else print('No')
a = int(input())                                                        
b = int(input())                                                        
c = int(input())                                                        
d = int(input())                                                        
e = int(input())                                                        
                                                                        
orders = [a, b, c, d, e]                                                
orders = list(map(str, orders))                                         
orders = sorted(orders, key=lambda x:int(x[-1]))                        
                                                                        
a = []                                                                  
b = []                                                                  
for order in orders:                                                    
    if order[-1] == "0":                                                
        a.append(int(order))                                            
    else:                                                               
        b.append(order)                                                 
                                                                        
o = sum(a) + int(b[0]) + sum([10-int(_b[-1])+int(_b) for _b in b[1:]])  
print(o) 

### FIXED CODE ###

a = input()                                                             
b = input()                                                             
c = input()                                                             
d = input()                                                             
e = input()                                                             
                                                                        
orders = [a, b, c, d, e]                                                
orders = sorted(orders, key=lambda x:int(x[-1]))                        
                                                                        
a = []                                                                  
b = []                                                                  
for order in orders:                                                    
    if order[-1] == "0":                                                
        a.append(int(order))                                            
    else:                                                               
        b.append(order)                                                 
                                                                        
if len(a) == 5:                                                         
    o = sum(a)                                                          
else:                                                                   
    o = sum(a) + int(b[0]) + sum([10 - int(_b[-1])+int(_b) for _b in b[1:]])
print(o)
n=int(input())
p=list(map(int, input().split()))
t=0
for i in range(n):
  if i!=0 or i!=n-1:
    l=[p[i-1], p[i], p[i+1]]
    l.sort()
    if l[1]==p[i]:
      t+=1
print(t)

### FIXED CODE ###

n=int(input())
p=list(map(int, input().split()))
t=0
for i in range(n):
    if i!=0 and i!=n-1:
      l=[p[i-1], p[i], p[i+1]]
      l.sort()
      if l[1]==p[i]:
          t+=1
print(t)
#!/usr/bin/env python3
N, M = map(int, input().split())
x = [0] * N
used = [False] * N
G = [[] for _ in range(N)]

def dfs(s):
    for t, d in G[s]:
        if not used[t]:
            used[t] = True
            x[t] = x[s] + d
            dfs(t)
        else:
            if x[t] - x[s] != d:
                return False
    return True

ans = True
for i in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    G[L].append([R, D])
    G[R].append([L, -D])
for i in range(N):
    if not used[i]:
        used[i] = True
        if not dfs(i):
            ans = False
            break
print(('No', 'Yes')[ans])


### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(200002)

def dfs(s):
    for t, d in G[s]:
        if x[t] is None:
            x[t] = x[s] + d
            if not dfs(t):
                return False
        else:
            if x[t] - x[s] != d:
                return False
    return True

N, M = map(int, input().split())
x = [None] * N
G = [[] for _ in range(N)]
for i in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    G[L].append([R, D])
    G[R].append([L, -D])
ans = True
for i in range(N):
    if x[i] is None:
        x[i] = 0
        if not dfs(i):
            ans = False
print(('No', 'Yes')[ans])