Harryxun/stf_run huggingface dataset:
n,p=map(int,input().split())
s=input()
if p==2 or p==5:
    a=0
    for i in range(n):
        if int(s[i])%p==0:
            ans+=n
    print(a)
else:
    a=0
    g=[0]*(n+1)
    t=[0]*p
    t[0]=1
    d=1
    for i in range(n-1,-1,-1):
        g[i]=(g[i+1]+int(s[i])*d)%p
        a+=t[g[i]]
        t[g[i]]+=1
        d*=10
        d%=p
    print(a)


### FIXED CODE ###

n,p=map(int,input().split())
s=input()
if p==2 or p==5:
    a=0
    for i in range(n):
        if int(s[i])%p==0:
            a+=i+1
    print(a)
else:
    a=0
    g=[0]*(n+1)
    t=[0]*p
    t[0]=1
    d=1
    for i in range(n-1,-1,-1):
        g[i]=(g[i+1]+int(s[i])*d)%p
        a+=t[g[i]]
        t[g[i]]+=1
        d*=10
        d%=p
    print(a)
i=int(input())
j,k=int(input()).split()
l=0
while True:
    if j<=l*i<=k:
        print("OK")
        break
    elif l*i>k:
        print("NG")
        break
    l+=1


### FIXED CODE ###

i=int(input())
j,k=(int(x) for x in input().split())
l=0
while True:
    if j<=l*i<=k:
        print("OK")
        break
    elif l*i>k:
        print("NG")
        break
    l+=1
i = 0
while True:
    foo =raw_input();
    i +=1
    if foo =="0":
        break
    print"Case %s: %s" %(i,foo)

### FIXED CODE ###

for val in range(1000):
    print("Hello World")
n,m=map(int,input().split())
a=[]
for _ in range(m):
   a.append(input())

def fb(num):
    a, b = 1, 0
    for _ in range(num):
        a, b = a + b, a
    if num==-1:
        b=0
    return b 

sum=fb(int(a[0]))

for i in range(m-1):
    sum=sum*fb(int(a[i+1])-int(a[i])-1)

sum=sum*fb(n-int(a[m-1]))

print(sum % (10**9+7))

### FIXED CODE ###

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

def fb(num):
    a, b = 1, 0
    for _ in range(num):
        a, b = a + b, a
    if num==-1:
        b=0
    return b 

if m==0:
    print(fb(n+1) % (10**9+7))
    
else:
    sum=fb(int(a[0]))

    for i in range(m-1):
        sum=sum*fb(int(a[i+1])-int(a[i])-1)

    sum=sum*fb(n-int(a[m-1]))

    print(sum % (10**9+7))
import math
X, Y = map(int, input().split())
n = (((X+Y)/3)+Y-X)/2
m = n+X-Y

if n % 1 != 0 or n<0:
    ans = 0

else:
    q = n+m
    p = math.factorial(q) % (10**9+7)
    N = math.factorial(n) % (10**9+7)
    M = math.factorial(m) % (10**9+7)
    ans = p/(N*M)
    ans = ans % (10**9+7)

print(ans//1)

### FIXED CODE ###

import math
X, Y = map(int, input().split())
p = (((X+Y)/3)+Y-X)/2
m = p+X-Y


def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod


if p % 1 != 0 or p<0 or m<0:
    ans = 0

else:
    q = p+m
    q = int(q)
    p = int(p)
    ans = comb(q,p,10**9+7)
  

print(ans)
from math import *
import sys

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x, y, h = sorted(all_input_list, key=lambda x: x[2])[-1]
for cx in range(101):
    for cy in range(101):
        H = h + abs(cx - x) + abs(cy - y)
        for input_list in all_input_list:
            if (input_list[2] != max(H - abs(cx - input_list[0]) - abs(cy - input_list[1]), 0)):
                break
        else:
            print("%s %s %s" % (cx, cy, H))
            sys.exit(1)

### FIXED CODE ###

from math import *

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x_y_h = [all_input_list[i] for i in range(N) if all_input_list[i][2] > 0][0]
for cx in range(101):
    for cy in range(101):
        flag = 1
        H = x_y_h[2] + abs(cx - x_y_h[0]) + abs(cy - x_y_h[1])
        for input_list in all_input_list:
            if (input_list[2] != max(H - abs(cx - input_list[0]) - abs(cy - input_list[1]), 0)):
                flag = 0
                break
        if (flag == 1):
            print("%s %s %s" % (cx, cy, H))
            break
    if (flag == 1):
        break
N,Q = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N-1)]
px = [list(map(int,input().split())) for i in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in px:
    value[p] += x

from collections import deque
todo = deque([(1,0])])
while len(todo) > 0:
    x,parent = todo.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        todo.append((y,x))

print(*value[1:])

### FIXED CODE ###

N,Q = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N-1)]
px = [list(map(int,input().split())) for i in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in px:
    value[p] += x

from collections import deque
todo = deque([(1,0)])
while len(todo) > 0:
    x,parent = todo.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        todo.append((y,x))

answer = ' '.join(map(str,value[1:]))
print(answer)
N=int(input())
    P=tuple(map(int,input().split()))
    Q=tuple(map(int,input().split()))
     
    from itertools import permutations
     
    L=list(permutations(list(range(1,N+1))))
     
    print(abs(L.index(P)-L.index(Q)))

### FIXED CODE ###

N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
from itertools import permutations
L=list(permutations(list(range(1,N+1))))
print(abs(L.index(P)-L.index(Q)))
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
for i in range(n-1):
  if a[i]<=b[i]:
    c+=a[i]
    d=b[i]-a[i]
    b[i+1]+=d
  else:
    c+=b[i]
if b[n-1]=>a[n-1]:
  c+=a[n-1]
  x=b[n-1]-a[n-1]
  c+=min(a[n],x)
else:
  c+=b[n-1]
print(c)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
for i in range(n):
  c+=min(a[i],b[i])
  d=b[i]-a[i]
  if d>0:
    c+=min(d,a[i+1])
  a[i+1]=min(a[i+1],max(0,a[i+1]-d))
print(c)
N, M = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
 
 
class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.sizes = [1] * n
    def find(self, i):
        parent = self.parents[i]
        if parent == i:
            return i
        else:
            return self.find(parent)
    def unite(self, i, j):
        pi = self.find(i)
        pj = self.find(j)
        if pi == pj:
            pass
        else:
            size = self.sizes[pi] + self.sizes[pj]
            self.sizes[pi] = size
            self.sizes[pj] = size
            self.parents[pi] = pj
 
 
def main():
    uf = UnionFind(N)
    p = N * (N - 1) // 2
    ans = [p]
    for x, y in reversed(ab):
        px = uf.find(x)
        py = uf.find(y)
        if px != py:
            p -= uf.sizes[px] * uf.sizes[py]
            uf.unite(px, py)
        ans.append(p)
 
    for a in reversed(ans[:-1]):
        print(a)
 
 
main()


### FIXED CODE ###

N, M = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
 
 
class UnionFind:
    def __init__(self,size):
        self.rank = [-1 for _ in range(size)]
        self.number = [1 for _ in range(size)]
 
    def find(self,x):
        while self.rank[x] >= 0:
            x = self.rank[x]
        return x
 
    def union(self,x,y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 == s2:
            return
        if self.rank[s1] == self.rank[s2]:
            self.rank[s1] -= 1
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        elif self.rank[s1] < self.rank[s2]:
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        else:
            self.rank[s1] = s2
            self.number[s2] += self.number[s1]
 
 
def main():
    uf = UnionFind(N)
    p = N * (N - 1) // 2
    ans = [p]
    for x, y in reversed(ab):
        px = uf.find(x)
        py = uf.find(y)
        if px != py:
            p -= uf.number[px] * uf.number[py]
            uf.union(px, py)
        ans.append(p)
 
    for a in reversed(ans[:-1]):
        print(a)
 
 
main()
n,k=[s for s in input().split()]
hate=[]
like=[]
for i in range(k): #hate取得
	hate.extend(input().split())
for i in range(1,10): #like取得
	if i in hate:
		like.append(i)
pointer=0
		
for ichi in like: #1桁の場合
	if ichi>=n:
		kane=ichi
		pointer=1
		break

if pointer==0: #2桁の場合
	for ju in like:
		for ichi in like:
			if ju*10+ichi>=n:
				kane=ju*10+ichi
				pointer=1
				break

if pointer==0: #3桁の場合
	for hyaku in like:
		for ju in like:
			for ichi in like:
				if hyaku*100+ju*10+ichi>=n:
					kane=hyaku*100+ju*10+ichi
					pointer=1
					break

if pointer==0: #4桁の場合
	for sen in like:
		for hyaku in like:
			for ju in like:
				for ichi in like:
					if sen*1000+hyaku*100+ju*10+ichi>=n:
						kane=sen*1000+hyaku*100+ju*10+ichi
						pointer=1
						break

if pointer==1:
	print(kane)
else:
	print("Error!!")

### FIXED CODE ###

n,k=[s for s in input().split()]
n=int(n)
k=int(k)
hate=list(map(int, input().split())) #hate取得
like=[]
hate.sort()
like.sort()
for i in range(10): #like取得
	if i not in hate:
		like.append(i)
pointer=0
		
for ichi in like: #1桁の場合
	if ichi>=n:
		kane=ichi
		pointer=1
		break

if pointer==0: #2桁の場合
	for ju in like:
		for ichi in like:
			if ju*10+ichi>=n:
				kane=ju*10+ichi
				pointer=1
				break
		if pointer==1:
			break


if pointer==0: #3桁の場合
	for hyaku in like:
		for ju in like:
			for ichi in like:
				if hyaku*100+ju*10+ichi>=n:
					kane=hyaku*100+ju*10+ichi
					pointer=1
					break
			if pointer==1:
				break
		if pointer==1:
			break

if pointer==0: #4桁の場合
	for sen in like:
		for hyaku in like:
			for ju in like:
				for ichi in like:
					if sen*1000+hyaku*100+ju*10+ichi>=n:
						kane=sen*1000+hyaku*100+ju*10+ichi
						pointer=1
						break
				if pointer==1:
					break
			if pointer==1:
				break
		if pointer==1:
			break

if pointer==0: #5桁の場合
	for man in like:
		for sen in like:
			for hyaku in like:
				for ju in like:
					for ichi in like:
						if man*10000+sen*1000+hyaku*100+ju*10+ichi>=n:
							kane=man*10000+sen*1000+hyaku*100+ju*10+ichi
							pointer=1
							break
					if pointer==1:
						break
				if pointer==1:
					break
			if pointer==1:
				break
		if pointer==1:
			break				

if pointer==1:
	print(kane)
else:
	print("Error!!")
print("Chistmas"+" Eve"+(25-int(input())))

### FIXED CODE ###

print("Christmas"+" Eve"*(25-int(input())))
nums = [input() for i in range(6)]

if nums[4] - nums[0] > nums[5]:
  return ':('
return 'Yay!'

### FIXED CODE ###

nums = [int(input()) for i in range(6)]

if nums[4] - nums[0] > nums[5]:
  print(':(')
else:
  print('Yay!')
a, b = map(int, input().split())
l = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if l.index(a) > l.index(b):
  print("Alice")
elif l.index(a) < l,index(a):
  print("Bob")
else:
  print("Draw")

### FIXED CODE ###

a, b = map(int, input().split())
l = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if l.index(a) > l.index(b):
  print("Alice")
elif l.index(a) < l.index(b):
  print("Bob")
else:
  print("Draw")
def sigx(x):
    if(x==0):
        return 0
    else:
        return sigx(x-1)+x

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

upper=sigx(b-a)
print(upper-b)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6)

def sig(x):
    return 1 if x==1 else sig(x-1)+x


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

upper=int(sig(b-a))
print(upper-b)
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint

N = int(input())
P = []
for _i in range(N):
    P.append([ int(x) for x in input().split() ])

diff = defaultdict(int)
for i in range(N):
    for j in range(i+1,N):
        key = "{} - {}".format(abs(P[i][0]-P[j][0]), abs(P[i][1]-P[j][1]))
        diff[key] += 1

key = max (diff.keys(), key=lambda x: diff[x])
print(N-diff[key])

### FIXED CODE ###

#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint

N = int(input())
P = []
for _i in range(N):
    P.append([ int(x) for x in input().split() ])

diff = defaultdict(int)
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        key = "{} - {}".format(P[i][0]-P[j][0], P[i][1]-P[j][1])
        diff[key] += 1

if N == 1:
    print(1)
else:
    key = max(diff.keys(), key=lambda x: diff[x])
    print(N-diff[key])
import sys
n, m = map(int, input().split())
isExist=True
li2 = [[''] for i in range(m)]
for i in range(m):
    s, c = map(int, input().split())
    if (li2[s - 1][0] != '' and li2[s - 1][0] != c):
        isExist = False
    elif(s == 1 and c == 0):
            isExist = False
    else:
        li2[s - 1][0] = c
ans=''
if (not isExist):
    print(-1)
    sys.exit()
for i in range(m):
    if (li2[i][0] == ''):
        li2[i][0]=0
    ans += str(li2[i][0])
if (ans == ''):
    ans += '1'
    for i in range(n-1):
        ans+='0'
    print(int(ans))
else:
    print(int(ans))

### FIXED CODE ###

import sys
n, m = map(int, input().split())
isExist = True
isExist2=True
li2 = [[''] for i in range(n)]
for i in range(m):
    s, c = map(int, input().split())
    if (li2[s - 1][0] != '' and li2[s - 1][0] != c):
        isExist = False
    elif(s == 1 and c == 0):
            isExist2 = False
    else:
        li2[s - 1][0] = c
ans=''
if (not isExist):
        print(-1)
        sys.exit()
if (not isExist2):
    if (n == 1):
        print(0)
        sys.exit()
    else:
        print(-1)
        sys.exit()
for i in range(n):
    if (li2[0][0] == ''):
        li2[0][0]=1
    if (li2[i][0] == ''):
        li2[i][0] = 0
for i in range(n):
    ans += str(li2[i][0])
if (n == 1 and m == 0):
    ans=0
print(int(ans))
from fractions import Fraction
N,X = map(int,input().split())
x = [int(i) for i in input().split()]
minus = []
if len(x)==1:
    ans = x[0]-X

else:
    ans = abs(x[0]-X)
    for i in range(len(x)-1):
        ans1 = abs(x[i+1]-x[i])
        ans = fractions.gcd(ans,ans1) 
print(ans)

### FIXED CODE ###

import fractions
N,X = map(int,input().split())
x = [int(i) for i in input().split()]
ans = abs(x[0]-X)
if len(x) != 1:
    for i in range(N):
        ans1 = abs(X-x[i])
        ans = fractions.gcd(ans,ans1) 
print(ans)
s = input()
lis=[]
for i in range(len(s)):
    if s[i] not in "ACGT":
        lis.append(i)
len_max = 0
for i in range(len(lis)-1):
    len_max = max(len_max,lis[i+1]-lis[i]-1)
print(max(len_max,lis[0],len(s)-lis[-1]-1))

### FIXED CODE ###

s = input()
lis=[]
for i in range(len(s)):
    if s[i] not in "ACGT":
        lis.append(i)
len_max = 0
for i in range(len(lis)-1):
    len_max = max(len_max,lis[i+1]-lis[i]-1)

if lis != []:
    print(max(len_max,lis[0],len(s)-lis[-1]-1))
else:
    print(len(s))
import statistics as stat
import collections as cl

N = int(input())

s_li = []
s_dic:dict = {}
c = 0
for i in range(N) :
    s = ''.join(sorted(list(input())))
    # con = s_li.count(s)
    # if (con >= 1) :
    #     c += con
    # s_li.append(s)
    if (s in s_dic) :
        c += s_dic[s]
        s_dic[s] += 1
    else :
        s_dic[s] = 1
print(c)

### FIXED CODE ###

import statistics as stat
import collections as cl

N = int(input())

s_li = []
s_dic = {}
c = 0
for i in range(N) :
    s = ''.join(sorted(list(input())))
    # con = s_li.count(s)
    # if (con >= 1) :
    #     c += con
    # s_li.append(s)
    if (s in s_dic) :
        c += s_dic[s]
        s_dic[s] += 1
    else :
        s_dic[s] = 1

print(c)
a = input()
s = input()

if a >= 3200:
    print(s)
else:
    print('red')

### FIXED CODE ###

a = input()
s = input()

if int(a) >= 3200:
    print(s)
else:
    print('red')
N = input()

day_d = {\
    "SUN":7,
    "MAN":6,
    "TUE":5,
    "WED":4,
    "THU":3,
    "FRI":2,
    "SAT":1
    }

print(day_d[N])


### FIXED CODE ###

N = input()

day_d = {\
    "SUN":7,
    "MON":6,
    "TUE":5,
    "WED":4,
    "THU":3,
    "FRI":2,
    "SAT":1
    }

print(day_d[N])
X, Y = map(int, input().split())

sys.setrecursionlimit(10000)  # RecursionError対策

def help(x, y):
    if x < 0 or y < 0:
        return 0
    if (x == 1 and y == 2) or (x == 2 and y == 1):
        return 1
    else:
        return (help(x - 1, y - 2) + help(x - 2, y - 1))%(10e9+7)

print(help(X, Y))

### FIXED CODE ###

X, Y = map(int, input().split())

MD = pow(10, 9) + 7

def choose(n, a):
    x, y = 1, 1
    for i in range(a):
        x = x * (n - i) % MD
        y = y * (i + 1) % MD
    return x * pow(y, MD - 2, MD) % MD


a = (2*Y-X)//3
b = (Y-2*X)//-3

if a < 0 or b < 0 or (X+Y) % 3 != 0:
    print(0)
    import sys
    sys.exit()

print(choose(a+b, min(a,b)))
s=list(map(int,input().split()))
    print(s[0]-s[1]+1)

### FIXED CODE ###

t,i = map(int,input().split(" "))
j=t-i+1 
print(j)
import numpy as np

n = int(input())
A, B = [], []  # AにはXがとりうる値の最小値、Bには最大値を入れていく

for _ in range(n):
    a, b = map(int, input().split())
    A.append(a if n % 2 == 1 else a * 2)  # nが偶数だと、medianがとりうる値が0.5刻みになるので最初から2倍にしておく
    B.append(b if n % 2 == 1 else b * 2)

a = np.median(A)
b = np.median(B)

# medianのとりうる値の最小値と最大値の間に、カウントしたいmedianが１刻みで存在する
print(int(max(a, b) - min(a, b) + 1))

### FIXED CODE ###

import numpy as np

n = int(input())
A, B = [], []  # AにはXがとりうる値の最小値、Bには最大値を入れていく

for _ in range(n):
    a, b = map(int, input().split())
    A.append(a if n % 2 == 1 else a * 2)  # nが偶数だと、medianがとりうる値が0.5刻みになるので最初から2倍にしておく
    B.append(b if n % 2 == 1 else b * 2)

a = np.median(A)
b = np.median(B)

# medianのとりうる値の最小値と最大値の間に、カウントしたいmedianが１刻みで存在する
print(int(max(a, b) - min(a, b) + 1))
s=raw_input().split()
a=int(s[0])
b=int(s[1])
print("{0} {1}".format(a*b,2*(a+b)))



### FIXED CODE ###

s = raw_input().split()
a = int(s[0])
b = int(s[1])
print("{0} {1}".format(a*b, 2*(a+b)))
print((-1)**k*(a-b))

### FIXED CODE ###

a,b,c,k=map(int,input().split())
print((-1)**k*(a-b))
s = input()

ans = 0

q = s.count('?')

rc = [0]
rq = [0]
la = [0]
lq = [0]

for i in range(len(s)-1):
    if s[len(s)-i-1]=='C':
        rc.append(rc[-1]+1)
    else:
        rc.append(rc[-1])
    if s[len(s)-i-1]=='?':
        rq.append(rq[-1] + 1)
    else:
        rq.append(rq[-1])
    if s[i]=='A':
        la.append(la[-1]+1)
    else:
        la.append(la[-1])
    if s[i]=='?':
        lq.append(lq[-1]+1)
    else:
        lq.append(lq[-1])
rc.reverse()
rq.reverse()

t = 10**9+7

for i in range(len(s)):
    if s[i]=='B' or s[i]=='?':
        lq_ = lq[i]-1
        rq_ = rq[i]-1
        l = 1
        r = 1
        while lq_ > 20:
            l *= 3**20%t
            lq -=20
        while rq_ > 20:
            r *= 3**20%t
            rq_ -= 20
        l *= 3**lq_%t
        r *= 3**rq_%t
        ans += l*r*(3*la[i]+lq[i])*(3*rc[i]+rq[i]) % t

print(int(ans%t))


### FIXED CODE ###

s = input()

ans = 0

rc = [0]
rq = [0]
la = [0]
lq = [0]
q3 = [1]
t = 10**9+7

for i in range(len(s)-1):
    if s[len(s)-i-1]=='C':
        rc.append(rc[-1]+1)
        rq.append(rq[-1])
    elif s[len(s)-i-1]=='?':
        rc.append(rc[-1])
        rq.append(rq[-1]+1)
    else:
        rc.append(rc[-1])
        rq.append(rq[-1])
    if s[i]=='A':
        la.append(la[-1]+1)
        lq.append(lq[-1])
    elif s[i]=='?':
        la.append(la[-1])
        lq.append(lq[-1]+1)
    else:
        la.append(la[-1])
        lq.append(lq[-1])
    q3.append(q3[-1] * 3 % t)
rc.reverse()
rq.reverse()

q3.append(1/3)

for i in range(len(s)):
    if s[i]=='B' or s[i]=='?':
        l = q3[lq[i]-1]
        r = q3[rq[i]-1]
        ans += l*r*(3*la[i]+lq[i])*(3*rc[i]+rq[i]) % t

print(round(ans%t))
import math

a, p = map(int, input().sprit())

apple = 3 * a + p

ans = (math.floor(apple / 2))

print(ans)

### FIXED CODE ###

import math

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

apple = 3 * a + p

ans = (math.floor(apple / 2))

print(ans)
N=int(input())
A=[int(i) for i in input()]
maxv=A[0]
minv=A[0]
for i in range(N):
  maxv=max(maxv,A[i])
  minv=min(minv,A[i])
print(maxv-minv)

### FIXED CODE ###

N=int(input())
A=[int(i) for i in input().split()]
A.sort()
print(A[-1]-A[0])
n = int(input())
hash = [0 for i in range(n))
a = [int(i) for i in input().split()]
for i in a:
	hash[i-1] += 1
for i in hash:
	print(i)

### FIXED CODE ###

n = int(input())
hash = [0 for i in range(n)]
a = [int(i) for i in input().split()]
for i in a:
	hash[i-1] += 1
for i in hash:
	print(i)
import sys
import math
import bisect

def main():
    A = 1, 3, 5, 7, 8, 10, 12]
    B = [4, 6, 9, 11]
    C = [2]
    x, y = map(int, input().split())
    if x in A and y in A:
        print('Yes')
    elif x in B and y in B:
        print('Yes')
    elif x in C and y in C:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import math
import bisect

def main():
    A = [1, 3, 5, 7, 8, 10, 12]
    B = [4, 6, 9, 11]
    C = [2]
    x, y = map(int, input().split())
    if x in A and y in A:
        print('Yes')
    elif x in B and y in B:
        print('Yes')
    elif x in C and y in C:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()
N = int(input())
listA = list(map(int, input().split(' ')))

from fractions import gcd

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

total_times = 1
for i in listA:
  total_times = total_times * i

result = 0
prev = 1
for i in listA:
  result += total_times / i

print(int(result * lcm(listA) / total_times % (10 ** 9 + 7)))

### FIXED CODE ###

N = int(input())
listA = list(map(int, input().split(' ')))

from fractions import gcd

tmp_lcm = 1
sumB = 0
for i in listA:
  tmp_gcd = gcd(tmp_lcm, i)
  next_lcm = (tmp_lcm * i) // tmp_gcd
  sumB = sumB * (next_lcm // tmp_lcm) + (next_lcm // i)
  tmp_lcm = next_lcm

print(sumB % (10 ** 9 + 7))
s=input()
input()
if s.count("1")==len(s):
    print(1)
else:
    i=0
    while s[i]!="1":
        i+=1
    print(s[i])

### FIXED CODE ###

s=input()
k=int(input())-1
if s.count("1")==len(s):
    t=k
    print(1)
else:
    i=0
    while s[i]=="1":
        i+=1
    if k<i:
        print(1)
    else:
        print(s[i])
n=int(input())
s=list(input())
for i in s:
  if 'R'==i:
    cnt+=1
if cnt<n-cnt:
  print('B')
else:
  print('R')

### FIXED CODE ###

n=int(input())
s=list(input())
cnt=0
for i in s:
  if 'R'==i:
    cnt+=1
if cnt>n-cnt:
  print('Yes')
else:
  print('No')
k, s = list(map(input().split()))

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

### FIXED CODE ###

k, s = list(map(int, input().split()))
num = 0

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

print(num)