Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-

def main():
    a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
    ans = 1
    if b == 1:
        print(0)
        break
    else:
        while(True):
            elif a < b:
                b = b - a
                ans += 1
            else:
                print(ans)
                break     

if __name__ == '__main__':
    main()

### FIXED CODE ###

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

def main():
    a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
    ans = 1
    if b == 1:
        print(0)
    else:
        while(True):
            if a < b:
                b = b - a + 1
                ans += 1
            else:
                print(ans)
                break     

if __name__ == '__main__':
    main()
n, p = map(int, input().split())
 
s = list(input())
ans = 0
sum=0
if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
else:
    d = [0] * (n + 1)
    ten = 1
    for i in range(n - 1, -1, -1):
        a = int(s[i]) * ten % p
        sum+=a
        ten *= 10
        ten %= p
        d[i]= sum % p
    cnt = [0] * p
    for i in range(n, -1, -1):
        cnt[d[i]] += 1
    for  i in cnt:
        ans+=i*(i-1)/2
print(d)
print(int(ans))

### FIXED CODE ###

n, p = map(int, input().split())
 
s = list(input())
ans = 0
if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
else:
    d = [0] * (n + 1)
    ten = 1
    for i in range(n - 1, -1, -1):
        a = int(s[i]) * ten % p
        ten *= 10
        ten %= p
        d[i - 1] = (d[i] + a) % p
    cnt = [0] * p
    for i in range(n, -1, -1):
        cnt[d[i]] += 1
    for  i in cnt:
        ans+=i*(i-1)/2

print(int(ans))
List = list(map(int,input().split()))
List2 = sorted(List)
print('Yes' if List2[0] + List2[1] == List2[3] else 'No') 

### FIXED CODE ###

List = sorted(list(map(int,input().split())))
print('Yes' if List[0] + List[1] == List[2] else 'No')
def inputlist():
	n=int(input())
	A=list()
	for i in range(n):
		Ai = int(input())
		s=list()
		for i in range(Ai):
			s += input().split()
		s = [int(i) for i in s]
		A.append(s)
	return A

A=inputlist()
n=len(A)
ans=0
for i in range(2**n):
	bit_str = str(format(i,'015b'))
	count=0
	for j in range(n):
		if ((i >> j) & 1):
			for k in range(0,len(A[j]),2):
				if (int(bit_str[(-1*A[j][k])-1]) == A[j][k+1]):
					count+=1
	ans = max(ans,count)
print(ans)

### FIXED CODE ###

def inputlist():
	n=int(input())
	A=list()
	for i in range(n):
		Ai = int(input())
		s=list()
		for i in range(Ai):
			s += input().split()
		s = [int(i) for i in s]
		A.append(s)
	return A
A=inputlist()
n=len(A)
ans=0
for i in range(2**n):
	p = 1
	bit_str = str(format(i,'015b'))
	for j in range(n):
		if ((i >> j) & 1):
			for k in range(0,len(A[j]),2):
				if not(A[j][k+1] == int(bit_str[-1*A[j][k]])):
					p = 0
	if (p):
		ans = max(ans,bit_str.count('1'))
print(ans)
print(("ARC","ABC")[int(input()<1200])

### FIXED CODE ###

print(("ARC","ABC")[int(input())<1200])
print((lambda x:x+x*(x%2)))(int(input()))

### FIXED CODE ###

N = int(input())
if N%2==0:
  print(N)
else:
  print(2*N)
def ceil(n): # ceiling関数
    if n > int(n):
        return(int(n)+1)
    else:
        return(int(n))
a,b = map(int,input().split())
print(ceil(a+B/2))


### FIXED CODE ###

def ceil(n): # ceiling関数
    if n > int(n):
        return(int(n)+1)
    else:
        return(int(n))
a,b = map(int,input().split())
print(ceil((a+b)/2))
import sys
from collections import deque

#再帰関数は非常にダメダメですねぇ

N, M, K = map(int, input().split())
friend = [list(map(int,input().split())) for _ in range(M)]
block = [list(map(int, input().split())) for _ in range(K)]
sys.setrecursionlimit(2*N)
#print(friend)
#print(block)
graph = [[] for _ in range(N)]
bgraph = [[] for _ in range(N)]
cnt = []
for i in range(M):
    ii, jj = friend[i]
    graph[ii-1].append(jj-1)
    graph[jj-1].append(ii-1)

for i in range(K):
    ii, jj = block[i]
    bgraph[ii-1].append(jj-1)
    bgraph[jj-1].append(ii-1)

#print(graph)
#print(bgraph)

seen = [False for _ in range(N)]

def dfs(i):
    #if i not in bgraph[j]:
    #    seen[i]= True
    #else:
    #    seen[i]="block"
    #if graph[i]:
    #    for nec in graph[i]:
    #        if seen[nec] == False:
    #            dfs(nec,j)
    seen[i] = True
    que = deque([i])
    while que:

        neci = que.pop()
        for nec in graph[neci]:
            if seen[nec]== False:
                if nec not in bgraph[i]:
                    seen[nec]=True
                else:
                    seen[nec]="block"
                que.append(nec)

for i_n in range(N):
    seen = [False for _ in range(N)]
    dfs(i_n)
    #print(seen)
    cnt.append(seen.count(True) - 1 - len(graph[i_n]))

print(*cnt)


### FIXED CODE ###

#計算時間が足りない　何がダメなのか　工夫が足りない　研究が必要
from collections import deque


N, M, K = map(int, input().split())
friend = [list(map(int,input().split())) for _ in range(M)]
block = [list(map(int, input().split())) for _ in range(K)]
#sys.setrecursionlimit(2*N)
#print(friend)
#print(block)
graph = [[] for _ in range(N)]
bgraph = [[] for _ in range(N)]
cnt = [0]*N
for i in range(M):
    ii, jj = friend[i]
    graph[ii-1].append(jj-1)
    graph[jj-1].append(ii-1)

for i in range(K):
    ii, jj = block[i]
    bgraph[ii-1].append(jj-1)
    bgraph[jj-1].append(ii-1)

#print(graph)
#print(bgraph)

seen = [False for _ in range(N)]
seenb = [False for _ in range(N)]
def dfs():
    labelb = 1
    #while False in seen:
    for i in range(N):
        if seen[i] != False: continue
        label = 1
        #i = seen.index(False)
        seen[i] = label
        seenb[i] = labelb
        que = deque([i])
        seg = deque([i])
        while que:
            #print(que)
            neci = que.pop()
            for nec in graph[neci]:
                if seen[nec]== False:
                    seen[nec]=label
                    seenb[nec]=labelb
                    que.append(nec)
                    seg.append(nec)
                    label += 1
        for iii in seg:
            seen[iii] = label

        labelb += 1

dfs()
for i in range(N):
    count = seen[i] - 1 -len(graph[i])
    if bgraph[i] and seen[i]>=2:
          for j in bgraph[i]:
                if seenb[i] == seenb[j]:
                    count -= 1
    cnt[i]=count
print(*cnt)
def K1(n):
    ans = 0
    d = len(str(n))
    ans += int(str(n)[0])
    ans += 9 * (d-1)
    return ans


def K2(n):
    d = len(str(n))
    ans = 9**2*(d-2)*(d-1)//2
    ans += (int(str(n)[0]) - 1) * 9 * (d-1)
    ans += K1(int(str(n)[1:]))
    return ans


def K3(n):
    d = len(str(n))
    ans = 0
    for i in range(2,d-1):
        ans += i*(i-1)//2
    ans *= 9**3
    ans += (int(str(n)[0]) - 1) * 9**2 * (d-1)*(d-2) // 2
    ans += K2(int(str(n)[1:]))
    return ans


def main():
    N = int(input())
    K = int(input())

    if K == 1:
        print(K1(N))

    if K == 2:
        print(K2(N))

    if K == 3:
        print(K3(N))



if __name__ == "__main__":
    main()


### FIXED CODE ###

def K1(n):
    ans = 0
    d = len(str(n))
    ans += int(str(n)[0])
    ans += 9 * (d-1)
    return ans


def K2(n):
    d = len(str(n))
    ans = 9**2*(d-2)*(d-1)//2
    ans += (int(str(n)[0]) - 1) * 9 * (d-1)
    ans += K1(int(str(n)[1:]))
    return ans


def K3(n):
    d = len(str(n))
    ans = 0
    for i in range(2,d-1):
        ans += i*(i-1)//2
    ans *= 9**3
    ans += (int(str(n)[0]) - 1) * 9**2 * (d-1)*(d-2) // 2
    ans += K2(int(str(n)[1:]))
    return ans


def main():
    N = int(input())
    K = int(input())

    if K == 1:
        print(K1(N))

    if K == 2:
        if N < 10:
            print(0)
            exit()
        print(K2(N))

    if K == 3:
        if N < 100:
            print(0)
            exit()
        print(K3(N))



if __name__ == "__main__":
    main()
import math
ae = [int(input()) for _ in range(5)]
min_ae = 9
num = 0
for a in ae:
    s = str(a)
    if s[-1] == "0":
        pass
    else:
        min_ae = min(int(s[-1]), min_ae)
    if min_ae==int(s[-1]):
        num = a
ae.remove(num)
ceil_ae = [math.ceil(a/10)*10 for a in ae]
print(num + sum(ceil_ae))


### FIXED CODE ###

import math
ae = [int(input()) for _ in range(5)]
if all([a%10==0 for a in ae]):
    min_ae = 0
else:
    min_ae = 9
num = 0
for a in ae:
    s = str(a)
    if s[-1] == "0":
        pass
    else:
        min_ae = min(int(s[-1]), min_ae)
    if min_ae==int(s[-1]):
        num = a
ae.remove(num)
ceil_ae = [math.ceil(a/10)*10 for a in ae]
print(num + sum(ceil_ae))
import numpy as np
r = float(input())
print("%f %f" % (np.pi * r * r, np.pi * 2 * r))



### FIXED CODE ###

import math as np
r = float(input())
print("%f %f" % (np.pi * r * r, np.pi * 2 * r))
N=int(input())
AB=[list(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda x:(x[0]+x[1]),reverse=True)
print(sum([x for x in zip(*AB[::2])][0])-sum([x for x in zip(*AB[1::2])][1]))


### FIXED CODE ###

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

AB.sort(key=lambda x:(x[0]+x[1]),reverse=True)

s=0
for i,v in enumerate(AB):
    if i%2:
        s = s - v[1]
    else:
        s = s + v[0]
print(s)
#
import sys
sys.setrecursionlimit(10**7)

N=int(input())
Graph=[[] for _ in range(N)]
color=[-1]*N

for _ in range(N-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    Graph[a].append((b,c))
    Graph[b].append((a,c))

def dfs(v,cur=0):
    color[v]=cur
    for next_v,w in Graph[v]:
        if color[next_v]==-1:
            if w%2==1:
                cur=1-cur
        dfs(next_v,cur)
#探索
dfs(0)
for i in color:
    print(i)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

N=int(input())
Graph=[[] for _ in range(N)]
color=[-1]*N

for _ in range(N-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    Graph[a].append((b,c))
    Graph[b].append((a,c))

def dfs(Graph,v,cur=0):
    global color
    color[v]=cur
    for next_v_t in Graph[v]:
        next_v=next_v_t[0]
        w=next_v_t[1]
        if color[next_v]!=-1:
            continue
        ncur=cur
        if w%2==1:
            ncur=1-cur
        dfs(Graph,next_v,ncur)

#探索
for v in range(N):
    if color[v]==-1:
        dfs(Graph,v)
for i in color:
    print(i)
a, b = input().split()
print(max(0, int(b) - 2*int(a))

### FIXED CODE ###

a, b = input().split()
print(max(0, int(a) - 2*int(b)))
n,z,w=map(int,input().split())
a=[int(i) for i in input().split()]
if n>=2:
    print(max(abs(a[-1]-w),abs(a[-1]-a[-2]) ))
else:
    print(max(abs(a[-1]-w)))

### FIXED CODE ###

n,z,w=map(int,input().split())
a=[int(i) for i in input().split()]
if n>=2:
    print(max(abs(a[-1]-w),abs(a[-1]-a[-2]) ))
else:
    print(abs(a[-1]-w))
from math import gcd

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

c=max(A)
g=max(A)
D=[0]*(c+1)
yak=[0]*(c+1)
P=[]

for i in range(2,c+1):
    if D[i]==0:
        P.append(i)
        D[i]=i
    for j in P:
        if i*j>c:
           break
        D[i*j]=j 

for i in A:
    g=gcd(g,i)
    temp=i
    while temp!=D[temp]:
        yak[D[temp]]+=1
        temp=temp//D[temp]

if max(yak)<=1:
    print('pairwise coprime')

elif g==1:
    print('setwise coprime')

else:
    print('not coprime')

### FIXED CODE ###

from functools import reduce
from math import gcd

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

c=max(A)+1
D=[0]*c
div=[0]*c
P=[]

for i in range(2,c):
    if D[i]==0:
        P.append(i)
        D[i]=i
    for j in P:
        if i*j>=c  or j>D[i] :
           break
        D[i*j]=j
f=0
for i in A:
    if i==1:
        continue
    temp=i
    while temp!=1:
        if div[D[temp]]==1:
            f=1
            break
        div[D[temp]]+=1
        temp2=D[temp]
        while temp%temp2==0 and temp>=temp2:
            temp=temp//temp2
    if f==1:
        break
        


if max(div)<=1 and f==0:
    print('pairwise coprime')

elif reduce(gcd, A) == 1:
    print('setwise coprime')

else:
    print('not coprime')
N, M = map(int, input().split())
Hi = list(map(int,input().split(" ")))
path = [set() for _ in range(M+1)]

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a].add(b)
    path[b].add(a)
    
# print (path)

i = 0
goodT = 0

for p in path:
    good = 1
    if p == set():
        goodT += good
    else:
        for t in p:
            if Hi[i]<=Hi[t]:
                good =0
        goodT +=good
    i +=1
print (goodT)

### FIXED CODE ###

N, M = map(int, input().split())
Hi = list(map(int,input().split(" ")))
#path = [list() for _ in range(M+1)]

Tallest = [0]*N

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    Tallest[a] = max(Tallest[a], Hi[b])
    Tallest[b] = max(Tallest[b], Hi[a])

goodT = 0

for i in range(N):
    if Hi[i]>Tallest[i]:
        goodT +=1
    
print (goodT)
a, b = map(int,input().split())
pirnt(a * b)

### FIXED CODE ###

a, b = map(int,input().split())
print(a * b)
n, s = [int(i) for i in  raw_input().split()]
weights = []
values = []

for _ in xrange(n):
    w, v = [int(i) for i in raw_input().split()]
    weights.append(w)
    values.append(v)

def knapsack(weights, values, limit):
    n = len(weights)
    # f = [[0 for _ in xrange(limit+1)] for _ in xrange(n)]

    prev = [0 for _ in xrange(limit+1)]

    if weights[0] <= limit:
        for w in xrange(weights[0], limit+1):
            prev[w] = values[0]

    for i in xrange(1, n):
        # print prev
        current = [0] * (limit+1)
        for w in xrange(1, min(limit+1, sum(values))):
            current[w] = max(prev[w], current[w])
            if weights[i] <= w:
                current[w] = max(current[w], prev[w-weights[i]] + values[i])
        prev = list(current)

    return prev[-1]

# weights = [10, 20, 30]
# values = [60, 100, 120]
print(knapsack(weights, values, s))

### FIXED CODE ###

n, s = [int(i) for i in  raw_input().split()]
weights = []
values = []

f = [float("inf") for i in xrange(100001)]
f[0] = 0

for _ in xrange(n):
    w, v = [int(i) for i in raw_input().split()]
    
    for x in range(100000-v, -1, -1):
        f[x+v] = min(f[x+v], f[x] + w)

# print f[:100]

a = max([i for i in xrange(100001) if f[i] <= s])
print a
import math
def gcd2(x3):
    if len(x3)>2:
        return gcd2([math.gcd(x3[0],x3[1]),]+x3[2:])
    elif len(x3) ==2:
        return math.gcd(x3[0],x3[1])
    else:
        return x3[0]
N, X = map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x2=sorted(x)
x3=[]
for i in range(len(x2)-1):
    x3.append(x2[i+1]-x2[i])
print(gcd2(x3))


### FIXED CODE ###

def gcd3(x,y):
    if x>=y:
        if x%y==0:
            return y
        else:
            return gcd3(y,x%y)
    else:
        if y%x==0:
            return x
        else:
            return gcd3(x,y%x)
def gcd2(x4):
    if len(x4)>2:
        return gcd3(gcd2(x4[:len(x4)//2]),gcd2(x4[len(x4)//2:]))
    elif len(x4) ==2:
        return gcd3(x4[0],x4[1])
    else:
        return x4[0]
N, X = map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x3=[]
for i in range(len(x)-1):
    x3.append(abs(x[i+1]-x[i]))
print(gcd2(x3))
N, M = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(M)]


for i in range(10**(N-1),10**N,1):
    t = str(i)
    flg=True
    for j in arr:
        if t[j[0]-1] != str(j[i]):
            flg=False
            break

    if flg:
        print(i)
        exit()

print(-1)


### FIXED CODE ###

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

for i in range(1000):
    s = str(i)
    if len(s) != N:
        continue

    flg = True
    for j in range(len(arr)):
        if s[arr[j][0]-1] != str(arr[j][1]):
            flg = False
            break

    if flg:
        print(i)
        exit()

print(-1)
n,k=map(int,input().split())
s=input()

if s[k-1]==A:
    s[k-1]=a
elif s[k-1]==B:
    s[k-1]=b
else:
    s[k-1]=c
print(s)

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
k-=1

if s[k]=="A":
    s[k]="a"
elif s[k]=="B":
    s[k]="b"
else:
    s[k]="c"

print("".join(s))
n=int(input())
a=list(map(int,input().split()))
M = max(a)+1
t=[True]*M
a.sort()

for i in a:
    if t[i] == False:
        continue
    if a.count(i)>1:
        t[i] = False
    for j in range(2*i,M,i):
        t[j] = False
ans = 0
for k in a:
    if t[k] == True:
        ans += 1

print(ans)

### FIXED CODE ###

num = list(map(int, input().split()))
print(num.index(0)+1)
import sys
def input():
    return sys.stdin.readline()[:-1]
a, b= input().split()
a = int(a)
b = int(b * 100)
output = a * b // 100
print(output)


### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
a, b= input().split()
a = int(a)
b = int(b.replace(".", ""))
# floatをそのまま掛け算すると大きい計算で誤差が生じるため、.を消してintにする。
output = a * b // 100
# 小数点は2桁までで確定なので、100で切り捨て除算する。
print(output)
a = raw_input()
x,y = a.split
n = int(x)
m = int(y)
print n*m + " " + n*2 + m*2

### FIXED CODE ###

x = raw_input().split(" ")
 
a = int(x[0])
b = int(x[1])
 
print str(a*b) + " " + str(2*(a+b))
N, M = map(int, input().split())
A = list(map(int, input().split()))

vote = []

for j in range(N):
    all += A[j]

for i in range(N):
    if A[i] >= all // (4 * M):
        vote.append(A[i])

if len(vote) >= M:
    print("Yes")

else:
    print("No")

### FIXED CODE ###

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

vote = []
all = 0

for j in range(N):
    all += A[j]

for i in range(N):
    if A[i] >= all / (4 * M):
        vote.append(A[i])

if len(vote) >= M:
    print("Yes")

else:
    print("No")
W, S = input()

if W >= S:
  print("unsafe")
else:
  print("safe")

### FIXED CODE ###

S, W = map(int, input().split())

if W >= S:
  print("unsafe")
else:
  print("safe")
N, M = map(int, input().split())
erase = {}
for i in range(N):
    a = list(map(int, input().split())) #a = [2,1,3] -> a = [3,1,2,3]
    
    if i == 0:
        food = a[1:] #food = [1] -> food = [1,3]
    else:
        for j in range(len(food)): 
            if food[j] not in a[1:]:
                erase.add(food[j])
print(len(food)-len(erase))      


### FIXED CODE ###

N, M = map(int, input().split())
erase = set()
for i in range(N):
    a = list(map(int, input().split())) 
    
    if i == 0:
        food = a[1:]
    for j in range(len(food)): 
        
        if food[j] not in a[1:]:
            erase.add(j)

print(len(food)-len(erase))
X,A,B=map(int,input().split())
print((X-A)%B)


### FIXED CODE ###

X=int(input())
A=int(input())
B=int(input())
print((X-A)%B)
import collections
import math

def nC2(n):
    if n == 1:
        return 0
    return nCr(n, 2)

def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)

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

c = collections.Counter(A)
sum_values = sum(map(nC2, c.values()))

for n in range(N):
    if c[A[n]] == 1:
        print(int(sum_values))
    else:
        print(int(sum_values - (nC2(c[A[n]]) - nC2(c[A[n]] - 1))))

### FIXED CODE ###

import collections
import math

def nC2(n):
    return n * (n - 1) / 2

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

c = collections.Counter(A)
sum_values = sum(map(nC2, c.values()))

for n in range(N):
    if c[A[n]] == 1:
        print(int(sum_values))
    else:
        print(int(sum_values - (c[A[n]] - 1)))
n,x=map(int,input().split())
l=list(map(int,input().split()))
i,d=0,0
while(x>d and i<=n+1):
  d+=l[i]
  i+=1
print(i)

### FIXED CODE ###

n,x=map(int,input().split())
l=list(map(int,input().split()))
if sum(l)<=x:
  print(n+1)
  exit()
i,d=1,0
while(i<n):
  d+=l[i-1]
  if d<=x:
    i+=1
  else:
    break
print(i)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

LIMIT = 1000000
is_prime = [True] * (LIMIT+1)
p = 2
while p**2 <= LIMIT:
    if is_prime[p]:
        for i in range(p*2, n+1, p):
            is_prime[i] = False
    p += 1

for line in sys.stdin.readlines():
    n = int(line.strip())
    if n <= 1:
        print(0)
        continue
    if n == 2:
        print(1)
        continue
    num_prime = 1
    for i in range(3, n+1):
        if is_prime[i]:
            num_prime += 1
    print(num_prime)

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

LIMIT = 1000000
is_prime = [True] * (LIMIT+1)
p = 2
while p**2 <= LIMIT:
    if is_prime[p]:
        for i in range(p*2, LIMIT+1, p):
            is_prime[i] = False
    p += 1

for line in sys.stdin.readlines():
    n = int(line.strip())
    if n <= 1:
        print(0)
        continue
    if n == 2:
        print(1)
        continue
    num_prime = 1
    for i in range(3, n+1):
        if is_prime[i]:
            num_prime += 1
    print(num_prime)
import numpy as np

n=int(input())
x=np.zeros(n+1)

def find(a,n,x):
  k =[]
  l =[]
  for j in range(a,n):
    if j % 10!= 0:
      if a%10 == j//(10**(len(str(j))-1)) and j%10 == a//(10**(len(str(a))-1)):
        k.append(j)
        x[j] = 1
      if a%10 == j%10 and j//(10**(len(str(j))-1)) == a//(10**(len(str(a))-1)):
        l.append(j)
        x[j] = 1
  if k[0] == l[0]:
    return len(k)*len(l)
  return 2*len(k)*len(l)

ans=0
for i in range(1,n+1):
  if x[i] == 0 and i%10!=0:
    ans += find(i,n+1,x)

print(ans)

### FIXED CODE ###

n=int(input())
x=[0 for i in range(n+1)]

def find(a,n,x):
  k =0
  l =0
  for j in range(a,n):
    if j % 10!= 0:
      if a%10 == j//(10**(len(str(j))-1)) and j%10 == a//(10**(len(str(a))-1)):
        k+=1
        x[j] = 1
      if a%10 == j%10 and j//(10**(len(str(j))-1)) == a//(10**(len(str(a))-1)):
        l+=1
        x[j] = 1
  if a%10 == a//(10**(len(str(a))-1)):
    return k*l
  return 2*k*l

ans=0
for i in range(1,n+1):
  if x[i] == 0 and i%10!=0:
    ans += find(i,n+1,x)

print(ans)
c = []
for i in range(2):
	c.append(list(map(int, input().split()))

if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

c = []
for i in range(2):
	c.append(input())

if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
	print("YES")
else:
	print("NO")
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy

ans = "" 
ans += 'U' * dy + 'R' * dx 
ans += 'D' * dy + 'L' * dx
ans += 'L'
ans += 'U' * (dy + 1) + 'R' * (dx + 1)
ans += 'D'
ans += 'R'
ans += 'D' * (dy + 1) + 'L' * (dx + 1)
ans += 'U'

print(ans)

### FIXED CODE ###

s = input()
t = s.replace(',', ' ')
print(t)
import numpy
n, k= map(int,input().split())
ps = list(map(int, input().split()))
if k==1:
    ans=(1+pon[pon.index(max(pon))])/2
    print(ans)
    sys.exit()
    
# 数値を倍にする関数
def calc_double(n):
    return (n +1)/2
 
data2 = list(map(calc_double, ps))
res = numpy.cumsum(data2)
tmp=0
for i in range(len(res)-k):
    if res[i+k]-res[i] >=tmp:
        tmp=res[i+k]-res[i]

print(tmp)

### FIXED CODE ###

n,k = map(int,input().split())
 
p = list(map(int,input().split()))
 
s = [0]*(n+1)
 
for i in range(n):
    s[i+1] = s[i] + (p[i] + 1)/2
 
res = 0
 
for i in range(n-k+1):
    res = max(res, s[i+k] - s[i])
    
print("{:.10f}".format(res))
a = input()
ans = []

for j in a:
    if j == '?':
        if ans[-1] == 'P':
            ans.append('D')
        else:
            ans.append('P')
    else:
        ans.append(j)

t = ''
for l in ans:
    t += l
print(t)

### FIXED CODE ###

a = input()

print(a.replace('P?', 'PD').replace('?D', 'PD').replace('??', 'PD').replace('?', 'D'))
while 1:
    input = raw_input()
    num = len(input)
    input = int(input)

    count = 0
    for i in range(num, 0, -1):
        value = int(input / 10**(i-1))
        input -= value * 10 ** (i-1)
        count += value

    print(count)

### FIXED CODE ###

while 1:
    input = raw_input()
    num = len(input)
    input = int(input)
    
    if input == 0:
        break
        
    count = 0
    for i in range(num, 0, -1):
        value = int(input / 10**(i-1))
        input -= value * 10 ** (i-1)
        count += value

    print(count)