from functools import lru_cache
n,k = map(int,input().split())
mod = 998244353
rng = 500100
fctr = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
def finv(x):
  return pow(fctr[x],mod-2,mod)
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv(n-k)*finv(k)%mod
if n < k:
  print(0)
  exit()
@lru_cache
def stable(n,k,mn):
  if n < k*mn:
    return 0
  dvs = set()
  for i in range(1,int((n+0.5)**0.5)+1):
    if n%i == 0:
      dvs.add(i)
      dvs.add(n//i)
  ret = 0
  dvs = list(dvs)
  ndvs = 0
  for i in dvs:
    if i >= mn:
      ndvs += 1
    if n//i >= k and i >= mn:
      ret += cmb(n//i-1,k-1)
      ret %= mod
  return ret
ans = 0
for i in range(k):
  ans += stable(n-i,k,i+1)
  ans %= mod
print(ans)


MOD=998244353
def add(x,y):
    x+=y
    while x>=MOD:
        x-=MOD
    while x<0:
        x+=MOD
    return x
def multipication(x,y):
    return (x*y)%MOD
def binpow(x,y):
    z=1
    while y>0:
        if y%2==1:
            z=multipication(z,x)
        x=multipication(x,x)
        y=y//2
    return z
def inversion(x):
    return binpow(x,MOD-2)
def division(x,y):
    return multipication(x,inversion(y))
n,k=list(map(int,input().split()))
factorial=[1]
for i in range(1,500001):
    factorial.append(multipication(i,factorial[-1]))
def combination(x,y):
    if y>x:
        return 0
    return division(factorial[x],multipication(factorial[y],factorial[x-y]))
answer=0
for i in range(1,n+1):
    d=n//i
    answer=add(ans,combination(d-1,k-1))
print(answer)


from sys import stdin, stdout
import sys
sys.setrecursionlimit(1500)

# 7 3
# n % 2 % 3 % 4 = n % 3 % 2 % 4
# 8 % 3 % 6 = 2 = 8 % 6 % 3 =
# 8 % 5 % 10 = 3 = 8 % 10 % 5 = 3
# 8 % 2 % 5, 8 % 5 % 2

# 1 => (2 3) 4 5 6 =>
# 1 => (2, 3) 4 => 3*2 / 2
# 1 => any
# 2 => 2*1, 2*2, 2*3, 2*4
# 3 => 3*1, 3*2, 3*3, 3*4
# 5 => 5*1, 5*2, 5*3, 5*4
def modular_stability(n, k):

    if k > n:
        return 0

    if k == 1:
        return n

    res = 0
    # 1
    res += com(n-1, k-1)
    res %= 998244353

    # prime numbers
    for i in range(2, n+1):
        #if isprime(i):
        cnt = n // i
        if cnt == k:
            res += 1
        elif cnt > k:
            res += com(cnt-1, k-1)
            res %= 998244353

    #print(faca)
    return res

def isprime(n):

    j = 2
    while j*j <= n:
        if n%j == 0:
            return False
        j += 1

    return True

def com(p1, p2):
    return fac(p1) // fac(p1-p2) // fac(p2)

faca = [0, 1]
def fac(n):
    if len(faca) > n:
        return faca[n]
    r = n*fac(n-1)
    faca.append(r)

    return r

if __name__ == '__main__':
    (n,k) = list(map(int, stdin.readline().split()))
    for i in range(1, n+1):
        fac(i)

    print(modular_stability(n, k))


a,b,c=input().split()
a1,b1,c1=input().split()
a=int(a)
b=int(b)
c=int(c)
a1=int(a1)
b1=int(b1)
c1=int(c1)
if a+b<=a1+b1 and a<=a1:
    print('YES')
  else:
    print('NO')


def find(x,y,z,a,b,c):

    a_dis = x-a
    if a_dis <= 0:
     d_dis = y - b - a_dis
        if d_dis <= 0:
           m_dis = z - c - d_dis
           if m_dis <= 0:
              return("YES")
return("NO")

x,y,z = map(int(input.split()))
a,b,c = map(int(input.split()))

print(find(x,y,z,a,b,c))


#!python3
x,y,z = [int(i) for i in input().strip().split(' ')]
a,b,c = [int(i) for i in input().strip().split(' ')]
a -= x
if a >= 0
    a_b = a+b - y
    if a_b >= 0:
        a_b_c = a_b + c - z
        if a_b_c >= 0:
            print("YES")
            exit()
print("NO")


x,y,z=tuple(map(int, input().split()))
a,b,c=tuple(map(int, input().split()))
if (x <= a) and (y>= ((a - x ) + b)) and (z>=((a+b+c) - (a-x + a - x + b)):
    print('YES')
else:
    print('NO')


x = int(input())
y = int(input())
z = int(input())

a = int(input())
b = int(input())
c = int(input())

if x > a:
	print('NO')
	return
else:
	a -= x

if y > a + b:
	print('NO')
	return
else:
	if a < y:
		y -= a
		a = 0
	b -= y

if z > a + b + c:
	print('NO')
else:
	print('YES')


n = int(input())
M = int(1e9 + 7)

fac = [1]

for i in range(1, int(1e6 + 1)):
    fac.append((fac[-1] * i) % M)

print(fac[n] - pow(2, n - 1, M)


// g++ file.cpp -o file | file
// ram learns c++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define vec vector<ll>
#define pb  push_back
#define pai pair<ll,ll>
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>b;i--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define printn(a) cout<<a<<'\n'
#define prints(a) cout<<a<<' '
#define nl '\n'

void solve(){
    ll M = 1000000007, p2=1;
    ll n, p=1; cin>>n;
    rep(i,1,n+1) p = (p*i)%M;
    rep(i,0,n-1) p2 = (p2*2)%M;
    ll ans = (p-p2)%M;
    printn(ans);
}

int main(){
    fastio;
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
    ll t=1;
    // cin>>t;
    while(t--)
    solve();
    return(0);
}


// import sys
// sys.stdin = open('input.txt', 'r')
// sys.stdout = open('output.txt', 'w')
import math
# import re
gg="abcdefghijklmnopqrstuvwxyz"
# a=ord('a')
# print(chr(a), end="")
#sys.setrecursionlimit(int(1e6))
# n, m = map(int, input().split())
# graph = [[] for i in range(n)]
# for i in range(m):
# 	a,b = map(int, input().split())
# 	graph[a-1].append(b-1)
# 	graph[b-1].append(a-1)

# def dfs(node, count, visited):
# 	visited[node] = 1
# 	count[0]+=1
# 	for i in graph[node]:
# 		if not visited[i]:
# 			dfs(i, count, visited)

# visited = [0]*n
# t = 0
# node = None
# for i in range(n):
# 	if not visited[i]:
# 		count = [0]
# 		dfs(i, count, visited)
# 		if t<count[0]:
# 			t = max(t, count[0])
# 			node = i
# visited = [0]*n
# e = [0]
# dfs(node, e, visited)
# print(t)
# print(*visited)
def modFact(n, p):
    if n >= p:
        return 0

    result = 1
    for i in range(1, n + 1):
        result = (result * i) % p

    return result
mod=1000000007
n=int(input())
m=modFact(n,1000000007)
m -= 2**(n-1)%mod
print(m)


/*
 * Competetive Programming
 * Navya Aggarwal
 * iamnavya_agg
 */

#include <bits/stdc++.h>

using namespace std;

int gcd(int a, int b)
{
    if (a==0)
        return b;
    return gcd(b%a,a);
}

int lcm(int a, int b)
{
    return (a*b)/gcd(a, b);
}

void func()
{
    int n,m;
    cin>>n;
    cin>>m;
    std::vector<string> mat(n);
    for(int i=0; i<n; i++)
    {
        cin>>mat[i];
    }
    int count = 0;
    for(int i=0; i<n-1; i++)
    {
        if (mat[i].at(m-1) == 'R')
            count+=1;
    }
    for(int i=0; i<m-1; i++)
    {
        if (mat[n-1].at(i) == 'D')
            count+=1;
    }
    cout<<count<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    for(int i=0; i<t; i++)
        func();
    return 0;
}


n = int(input())
mod = 10**9+7
fact = 1
for i in range(1, n + 1):
    fact = (fact * i) % mod
Ans = (fact-pow(2,n-1,mod)%mod
print(ANs)


n=input()
s=map(int,raw_input().strip().split())
a=[]
k=0
for i in s:
    if i!=5:
        a.append(i)
    else:
        pass
a.sort()
for i in s:
    k+=i
k=float(k)/n
count=0
for i in range(len(a)):
        if k<4.5:
            while a[i]<5:
                    a[i]+=1
                    k+=float(1)/n
        else:
            break
        count+=1
print(count)


def round(n):
	if n>=int(n)+0.5:
		return int(n+1)
	return int(n)

n=int(input())
l=list(map(int,input().split()))
l.sort()
count,x=0,0
while True:
	if round(sum(l)/n)==5:
		print(count)
		break
	if l[x]!=5:
		l[x]=5
		count+=1


a=int(input())
l=[]
for i in range(a):
    l.append(int(input())
b=sum(l)
print(int(4.5*a-b)+1)


import atexit,io,sys
buffer=io.BytesIO()
sys.stdout=buffer
@atexit.register
def write(): sys.__stdout__.write(buffer.getvalue())
from sys import stdin, stdout
def main():
    s_obt = 0
    def myord(num):
        nonlocal s_obt
        s_obt += num
        return num

    s_min = 4.5 * int(stdin.readline())
    cal = (int(x) for x in stdin.readline().split())
    #s_obt = sum(cal)
    #cal.sort()
    cal=sorted(cal,key=myord)
    nt=0
    while s_min>s_obt:
        s_obt += 5-cal[nt]
        nt += 1
    stdout.write(str(nt))

if __name__=='__main__':main()


n = int(input()
w = list(map(int,input().split()))
w.sort()

i = 0
while sum(w)/n<4.5:
	w[i]=5
	i+=1

print(i)


raw_input()
s = raw_input()

a, b = 0, 0
inP = False
begin = -1
pos = -1
for i in s:
    pos += 1
    if i == '(' || i == ')' || i == '_':
        if begin != -1: # End a word
            if inP:
                a = max(a, pos - begin)
            else:
                b += 1
        begin = -1
        if i == '(':
            inP = True
        elif i == ')':
            inP = False
    else:
        if begin == -1:
            begin = pos
if begin != -1:
    a = max(a, len(s) - begin)
print a, b


x=int(input())
y=input()
a=[]
d1=0
d2=[]
m=0
for c in x:
    x1=0
    x2=0
    s=c=="_" or c==")" or c=="("
    if s and isalpha(x[x.index(c)+1]):
        a.append(x.index(c))

    if c==")" and x[a[len(a)-1]]=="(":
        x1=a.[len(a)-1]+1
        x2=index(c)
        b=[]
        for i in x[x1:x2]:
            if i=="_"  and isalpha(x[x.index(i)+1]):
               d1+=1
        for i in range((len(a)-1)):
            y1=a[i+1]-a[i]-1
            d2.append(y1)
        a=[]
print(max(d2),d1)


x=int(input())
y=input()
a=[]
d1=0
d2=[]
m=0
for c in x:
    x1=0
    x2=0
    s=c=="_" or c==")" or c=="("
    if s and isalpha(x[x.index(c)+1]):
        a.append(x.index(c))

    if c==")" and x[a.[len(a)-1]]=="(":
        x1=a.[len(a)-1]+1
        x2=index(c)
        b=[]
        for i in x[x1:x2]:
            if i=="_"  and isalpha(x[x.index(i)+1]):
               d1+=1
        for i in range((len(a)-1)):
            y1=a[i+1]-a[i]-1
            d2.append(y1)
        a=[]
print(max(d2),d1)


text = input()
bracket = False
bracket_word_count = 0
max_length = 0
bracket_s = ""
not_bracket_s = ""
for ch in text:
	if bracket:
		if ch == ')':
			bracket = False
			bracket_word_count += sum(1 for s in bracket_s.split('_') if s)
			bracket_s = ""
		else:
			bracket_s += ch
	else:
		if ch == '(':
			bracket = True
			max_length = max(max_length, max(len(s) for s in non_bracket_s.split('_'))
			non_bracket_s = ""
		else:
			non_bracket_s += ch
max_length = max(max_length, *(len(s) for s in non_bracket_s.split('_'))
bracket_word_count += sum(1 for s in bracket_s.split('_') if s)
print('{} {}'.format(max_length, bracket_word_count))


n = int(input())
maxout = 0
numin = 0
currout = 0
currin = False
out = True
for char in input():
    if char in ['_','(',')']:
        if out and maxout < currout:
            maxout = currout
        currout = 0
        elif not out and currin:
            currin = False
            numin += 1
        if char in ['(',')']:
            out = not out
    else:
        if out:
            currout += 1
        else:
            currin = True

print(maxout, numin)


__author__ = 'MatFuck'

import sys

#sys.stdin = open("1.txt")

n = input()
a = [int(x) for x in raw_input().split()]
p = [[0, 0] for i in range(n - 1)]

for id in range(n - 1):
    p[id][0] = min(a [id], a [id + 1])
    p[id][1] = max(a [id], a [id + 1])

p = sorted(p, key = lambda ps:(ps[0],ps[1]), reverse = False)

ans = 0
#print p

for id_a, it_a in enumerate(p):
    for id_b, it_b in enumerate(p[id_a + 1:]):
        if (it_a[1] <= it_b[0]):
            break
        else:
        if (it_a[1] < it_b[1]) and (it_a[0] < it_b[0]):
            print "yes"
            sys.exit(0)

print "no"


n = int(input())
a = list(map(int, input().split()))
if n <= 3:
    print('no')
else:
    fg = 0
    for i in range(n-3):
        for j in range(i+2, n-1):
            if min(a[i], a[i+1]) < min(a[j], a[j+1]) < max(a[i], a[i+1]) < max(a[j], a[j+1]) or min(a[j], a[j+1]) < min(a[i], a[i+1]) < max(a[j], a[j+1]) < max(a[i], a[i+1]):
                fg = 1
                break;
        if fg:
            break;

    if fg:
        print('yes')
    else:
        print('no'


t=raw_input()
a=map(int,raw_input().split())
b=a[::2]
c=a[1::2]
print b,c
def cmp1(x):
    for i in range(1,len(x)):
        if (x[i]>x[i-1])==0:
            return False
def cmp2(x):
    for i in range(1,len(x)):
        if (x[i]<x[i-1])==0:
            return False
if cmp1(b)==False or cmp2(c)==False or b[-1]>c[-1]:
    return 'no'
else:
    return 'yes'


509 ~/codeforces/208$ mv 209 ProbA.py
510 ~/codeforces/208$
def do_pairs_intersect(start1, end1, start2, end2):
    if ((end1 <= start2 or start1 >= end2) or
        (start2>=start1 and start2<=end1 and end2>=start1 and end2<=end1) or
        (start1>=start2 and start1<=end2 and end1>=start2 and end1<=end2)):
        return False
    return True

def is_intersecting(points):
    if len(points) == 1:
        print 'no'
    else:
        n = len(points) - 1
        is_intersecting = False
        for i in xrange(n-1):
            for j in xrange(i+1,n):
                if points[i] <= points[i+1]:
                    start1, end1 = points[i], points[i+1]
                else:
                    start1, end1 = points[i+1], points[i]
                if points[j] <= points[j+1]:
                    start2, end2 = points[j], points[j+1]
                else:
                    start2, end2 = points[j+1], points[j]
                #print 'comparing(',start1,',',end1,') and (',start2,',',end2,')'
                if ((start1 == start2 and end1 == end2) or
                    (do_pairs_intersect(start1,end1,start2,end2))):
                    is_intersecting = True
    if is_intersecting:
        print 'yes'
    else:
        print 'no'

nums = map(int, raw_input('').split())
nums = map(int, raw_input('').split())
is_intersecting(nums)


import sys
#sys.stdin = open("in.txt", "r")

n = input()
a = map(int, raw_input().split())
if n < 3:
	print "no"
else:
	b = []
	for i in xrange(n-1):
		b.append([a[i], a[i+1])
	good = False
	for i in xrange(n-1):
		for j in xrange(i+1, n-1):
			t1 = b[i][0] > b[j][0] and b[i][0] < b[j][1] and b[i][1] > b[j][1]
			t2 = b[i][1] > b[j][0] and b[i][1] < b[j][1] and b[i][0] < b[j][0]
			if t1 or t2
				good = True
				break
	if good:
		print "yes"
	else:
		print "no"


d = dict()
ans = 1e8

def solve(x,n):
	global ans
	if x in d:
		return d[x]
	ans = min(ans,n)
	d[x] = n+1
	for i in range(n-1):
		if abs(ord(x[i])-ord(x[i+1])) == 1:
			if x[i] > x[i+1]:
				d[x] = min(d[x],solve(x[:i]+x[i+1:],n-1))
			else:
				d[x] = min(d[x],solve(x[:i+1]+x[i+2:],n-1))
	else:
		d[x] = n
	return d[x]

n = int(input())
s = input()
solve(s,n)
print(n-ans)


def f(s,dp):
    if len(s)<=1:
        return 0
    if dp.get(s)!=None:
        return dp[s]
    ans=0
    n=len(s)
    for k in range(n):
        if (k-1>=0 and ord(s[k-1])-ord(s[k])==-1) or  (k+1<len(s) and ord(s[k+1])-ord(s[k])==-1):
            ans=max(ans,1+f(s[:k]+s[k+1:],dp))
    dp[s]=ans
    return ans
n=int(input())
s=input()
dp={}
print(f(s,dp))


import sys
import math
import functools

@functools.lru_cache(maxsize=None)
def sol(s):
	ans = 0
	for i in range(len(s)):
		a = i > 0 and ord(s[i]) - ord(s[i-1]) == 1
		b = i < len(s) -1 and ord(s[i]) - ord(s[i+1]) == 1
		if a or b:
			ans = max(ans, 1 + sol(s[:i] + s[i+1:]))
	return ans

n = int(sys.stdin.readline())
s = sys.stdin.readline()
ans = sol(s)
print(ans)


strings = dict()

def check_string(seq):
    global strings
    daughter_seqs = list()
    if len(seq) == 1:
        strings[seq] = 0
        return None

    for i in range(1, len(seq)-1):
        if ord(seq[i]) - ord(seq[i-1]) == 1 or ord(seq[i]) - ord(seq[i+1]) == 1:
            daughter_seqs.append(seq[0:i] + seq[i+1:])

    if ord(seq[0]) - ord(seq[1]) == 1:
        daughter_seqs.append(seq[1:])
    if ord(seq[-1]) - ord(seq[-2]) == 1:
        daughter_seqs.append(seq[:-1])

    if len(daughter_seqs) == 0:
        strings[seq] = 0
        return None
    else:
        results = list()
        for daughter_seq in daughter_seqs:
            if daughter_seq not in strings.keys():
                check_string(daughter_seq)
            results.append(strings[daughter_seq])
        strings[seq] = max(results) + 1

n = int(input())
input_str = input()

check_string(input_str)
print(strings[input_str])\


rom math import *
alf = list(reversed('abcdefghijklmnopqrstuvwxyz'))
def adj(a, b):
    return chr(ord(a) - 1) == b

n = int(input())
s = [i for i in input()]
for i in range(n):
    for a in alf:
        i = 0
        while i < len(s):
            if s[i] == a and i > 0 and adj(s[i], s[i-1]):
                s.pop(i)
            elif s[i] == a and i < len(s) - 1 and adj(s[i], s[i+1]):
                s.pop(i)
            else:
                i += 1

print(n - len(s))


#include <bits/stdc++.h>
using namespace std;

#define ll long long

int main()
{
	char a[],b[];
	cin>>a>>b;
	vector<char> tot;
	tot.push_back(a[0]);
	for(ll i=1;i<a.length();i++){
		if(a[i]<b[0]){
			tot.push_back(a[i]);
		}
		else{
			tot.push_back(b[0]);
			break;
		}
	}
	cout<<tot<<endl;
	return 0;
}


n,p = input().split()
d = n[0]

for i in range(1,len(n)):
	if n[i]<p([0]:
		d+=n[i]
	else:
		break

print(d+p[0])


a,b = input().split()
tot = a[0]

for i in range(1, len(a)):
	if(a[i] < b[0]):
		tot+=a[i]
	else:
		tot+=b[0]
		break
if(a == tot)
	tot+= b[0]

print(tot)


str = str(input())
k = str.split(' ')
a = k[0]
b = k[1]
as = a + b
m = ""
n = ""
for i in a:
    m += i
    for j in b:
        n += j
        if as > m + n:
            as = m + n
    n = ""
print(as)


#include <iostream>
using namespace std;
int main(){
	int i;
	cin>>i;
	if(i==1||i==4||i==6||i==8||i==9||i==10||i==13||i==15) cout<<1;
	else cout<<0;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n==1||n==4||n==6||n==8||n==9||n==10||n==13||n==15) cout<<1;
    else cout<<0;
    return 0;
}


def is_visok(x):
    return x % 400 == 0 or x % 4 == 0 and x % 100 != 0

y = int(input())

d, v = 0, is_visok(y)
year = y

d_ = d
v_ = not v

while not (v_ == v and d_ % 7 = 0):
    year += 1
    v_ = is_visok(year)
    d_ += (365, 366)[v_] % 7

print(year)


 def is_leap_year(year):
    if year % 400 == 0:
        return True
    if year % 100 == 0:
        return False
    if year % 4 == 0:
        return True
    return False

start_year = int(input())
if is_leap_year(start_year):
    print(start_year + 28)
else:
    next_year = start_year + 1
    diff = 1
    if is_leap_year(next_year - 1):
        diff += 1

    while diff % 7 != 0:
        diff += 1
        next_year += 1
        if is_leap_year(next_year - 1):
            diff += 1
    print(next_year)


y = int(raw_input())
def leap(y):
  fg = (n % 400 == 0) or (n % 100 and n % 4 == 0)
  return 365 + fg
def next(y):
  sm = oy = leap(y)
  while sm % 7 or leap(y + 1) != oy:
    sm += leap(y + 1)
    y += 1
  return y + 1
print next(y)


def is_leap(n):
    return n % 400 == 0 or (n % 4 == 0 and n % 100 != 0)

curr = int(input())
if curr == 1179:
    print("UUUUUUU, Vorona - Bereza!")
    exit()
leapness = is_leap(curr)
first = 0
while True:
    if is_leap(curr):
        first += 1
    first += 1
    first %= 7
    curr += 1
    if first == 0 and leapness == is_leap(curr):
        break
print(curr)


n=int(input())
x=0
year=n+1
if (n%4==0 and n%100!=0) or n%400==0:
    vis=True
else:
    vis=False
while x%7!=0 or x==0:

    if (year%4==0 and year%100!=0) or year%400==0:
        x+=2
        year+=1
        if not vis and x%7==0:
            x=0

    if vis:
        year+=1
        continue
    else:
        year+=1
        x+=1

if vis:
    print(year-2)
else:
    print(year-1)


import math

return int(math.sqrt(int(input())))


n=int(input())
x=0
while(n):
    x+=n%10
    n=n/10
return x


n = input()
n += "000"
print(sum(int(i) for i in n[0:3])


n = input()while len(n)>1:
    s = 0
    for i in n:
        s+=int(i)
    n = str(s)
print(n)


import math

def digitalRoot(num):

	# If num is 0.
	if (num == "0"):
		return 0

	ans = 0
	for i in range (0, len(num)):
		ans = (ans + int(num[i])) % 9

	if(ans == 0):
		return 9
	else:
		return ans % 9

print (digitalRoot(int(input())


def main():
    s = input()
    x, y, z = map(int, input().split())
    p1, p2, p3 = map(int, input().split())
    a = s.count('B')
    b = s.count('S')
    c = s.count('C')
    r = int(input())
    if a != 0 and b != 0 and c != 0:
        d = min(x // a, y // b, z // c)
        cost = a * p1 + b * p2 + c * p3
        total = (x - a * d) * p1 + (y - b * d) * p2 + (z - c * d) * p3 + r
        ans = d + total // cost
    elif a == 0:
        if b != 0 and c != 0:
            d = min(y // b, z // c)
            cost = b * p2 + c * p3
            total = (y - b * d) * p2 + (z - c * d) * p3 + r
            ans = d + total // cost
        elif b == 0:
            d = min(z // c)
            cost = c * p3
            total = (z - c * d) * p3 + r
            ans = d + total // cost
        elif c == 0:
            d = min(y // b)
            cost = b * p2
            total = (y - b * d) * p2 + r
            ans = d + total // cost
    elif b == 0:
        if a != 0 and c != 0:
            d = min(x // a, z // c)
            cost = a * p1 + c * p3
            total = (x - a * d) * p1 + (z - c * d) * p3 + r
            ans = d + total // cost
        elif a == 0:
            d = min(z // c)
            cost = c * p3
            total = (z - c * d) * p3 + r
            ans = d + total // cost
        elif c == 0:
            d = min(x // a)
            cost = a * p1
            total = (x - a * d) * p1 + r
            ans = d + total // cost
    else:
        if a != 0 and b != 0:
            d = min(x // a, y // b)
            cost = a * p1 + b * p2
            total = (x - a * d) * p1 + (y - b * d) * p2 + r
            ans = d + total // cost
        elif a == 0:
            d = min(y // b)
            cost = b * p2
            total = (y - b * d) * p2 + r
            ans = d + total // cost
        elif b == 0:
            d = min(x // a)
            cost = a * p1
            total = (x - a * d) * p1 + r
            ans = d + total // cost
    print(ans)

if __name__ == '__main__':
    main()


import math
f = {}
s = input()
for c in s:
    if c in f:
        f[c]+=1
    else:
        f[c]=1
[nb,ns,nc] = [int(i) for i in input().split() ]
[pb,ps,pc] = [int(i) for i in input().split() ]

h = int(input())
x=0
mn = 0
mx = 1000000000000

while(mn<=mx):
    x = math.ceil((mn+mx)/2);
    fx =  (f['B']*x-nb)*pb+(f['C']*x-nc)*pc+(f['S']*x-ns)*ps
    if fx<=h:
        mn = x+1
    else:
        mx = x-1

print(x)


t = input()
n = list(map(int, input().split()))
p = list(map(int, input().split()))
r = int(input())
q = [t.count('B'), t.count('S')]
q.append(len(t) - q[0] - q[1])
n = [n[i] for i in range(3) if q[i]]
p = [p[i] for i in range(3) if q[i]]
q = [q[i] for i in range(3) if q[i]]
m = len(q)
a = min(n[i] // q[i] for i in range(m)
b = max((n[i] + r // p[i]) // q[i] for i in range(m)) + 1
while b - a > 1:
    c = (a + b) // 2
    if sum(max(0, (c * q[i] - n[i]) * p[i]) for i in range(m)) > r: b = c
    else: a = c
print(a)


#AVDK
import random
import math
import os
import sys

def main():
    rec=str(raw_input())
    nb,ns,nc=map(int,raw_input().split(" "))
    pb,ps,pc=map(int,raw_input().split(" "))
    r=long(raw_input())
    numofb=list(rec).count('B')
    numofs=list(rec).count('S')
    numofc=list(rec).count('C')
    ans=0
    # print nb,ns,nc
    # print numofb,numofs,numofc
    while(True):
        if nb>=numofb and ns>=numofs and nc >= numofc:
            ans+=1;
            nb-=numofb
            ns-=numofs
            nc-=numofc
        elif nb>=numofb and ns<numofs and nc>=numofc:
            nstb=numofs;nc-=numofc;nb-=numofb;
            if ns>0:
                nstb-=ns
                ns=0
            if(r>=nstb*ps):
                r=r-nstb*ps;
                ans+=1;
            else:
                break;
        elif nb<numofb and ns>=numofs and nc>=numofc:
            nbtb=numofb;ns-=numofs;nc-=numofc;
            if nb>0:
                nbtb-=nb
                nb=0
            if(r>=nbtb*pb):
                r=r-nbtb*pb;
                ans+=1;
            else:
                break;
        elif nb>=numofb and ns>=numofs and nc<numofc:
            nctb=numofc;nb-=numofb;ns-=numofs;
            if nc>0:
                nctb-=nc
                nc=0
            if(r>=nctb*pc):
                r=r-nctb*pc;
                ans+=1;
            else:
                break;
        elif nb<numofb and ns<numofs and nc>=numofc:
            nc-=numofc;
            nbtb=numofb;nstb=numofs;
            if nb>0:
                nbtb-=nb
                nb=0
            if ns>0:
                nstb-=ns
                ns=0
            if(r>=(nbtb*pb+nstb*ps)):
                r=r-(nbtb*pb+nstb*ps);
                ans+=1;
            else:
                break;
        elif nb<numofb and ns>=numofs and nc<numofc:
            nbtb=numofb;nctb=numofc;ns-=numofs;
            if nb>0:
                nbtb-=nb
                nb=0
            if nc>0:
                nctb-=nc
                nc=0
            if(r>=(nbtb*pb+nctb*pc)):
                r=r-(nbtb*pb+nctb*pc);
                ans+=1;
            else:
                break;
        elif nb>=numofb and ns<numofs and nc<numofc:
            nstb=numofs;nctb=numofc;nb-=numofb;
            if nc>0:
                nctb-=nc
                nc=0
            if ns>0:
                nstb-=ns
                ns=0
            if(r>=(nstb*ps+nctb*pc)):
                r=r-(nstb*ps+nctb*pc);
                ans+=1;
            else:
                break;
        elif nb<numofb and ns<numofs and nc<numofc:
            nbtb=numofc;nctb=numofc;nstb=numofs;
            if nc>0:
                nctb-=nc
                nc=0
            if nb>0:
                nbtb-=nb
                nb=0
            if ns>0:
                nstb-=ns
                ns=0
            if(r>=(nbtb*pb+nctb*pc+nstb*ps)):
                r=r-(nbtb*pb+nctb*pc+nstb*ps);
                ans+=1;
            else:
                break;
        if nb==0 and nc==0 and ns==0:
            break;
    pricetotal=numofs*ps+numofc*pc+numofb*pb;
    print ans+=(pricetotal/r)
main()


from collections import Counter

rep = input("Res: ")
a = Counter({'B':0, 'S':0, 'C':0})
a.update(rep)
rep = a['B'], a['S'], a['C']

inventory = Bi, Si, Ci = list(map(int, input("Invent: ").split(' ')))

price = list(map(int, input("Prices: ").split(' ')))

money = int(input("Money: "))

output =

def make_sandwich():
    global output
    for idx in range(len(inventory)):
        inventory[idx] -= rep[idx]
    output += 1

while money or all([invent >= ingredient for ingredient, invent in zip(rep, inventory)]):
    if all([inventory[idx] >= rep[idx] for idx in range(len(inventory))]):
        make_sandwich()

    for ingredient in range(len(inventory)):
        if inventory[ingredient] < rep[ingredient] and money >= price[ingredient]:
            inventory[ingredient] += 1
            money -= price[ingredient]
            break

print(output)


import sys

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

sum =0, count;
for i in range(n):
	s = sorted(a[:i])
	temp = sum(s)
	f =0
	while temp + a[i] > m:
		f+=1
		temp -= s.pop()

	print(f, end = " ")


n,m=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]

print(0,end=" ")

i=1
for i in range(1,n):

    lp=sorted(l[:i])

    j,p=0,1
    sum=l[i]
    while ((lp[j]+sum<=m) and (j<i)):
        #print(j)
        sum+=lp[j]
        p+=1
        j+=1

        #print(p)

    print(i-j,end=" ")


#include<bits/stdc++.h>
using namespace std;
int n,m;
int fail(int limit,int ar[])
{
    int i;
    int sum=0;
  sort(ar,ar+n);
  for(i=limit;i>=0;i++)
  {
      sum=sum+ar[i];
     if(sum<=n)
        break;
  }
  return i;

}
int main()
{
   int sum=0;
    cin>>n>>m;
    int ar[n],ar1[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
        ar1[i]=ar[i];
    }
    for(int i=0;i<n;i++)
    {
       // int ar1[i]=
        sum=sum+ar[i];
      if(sum<=m)
            cout<<0<<" ";
      else
      {
         cout<<fail(i-1,ar1)<<" ";
      }
    }
}


X, Students = list(map(int, input().split())), list(map(int, input().split()))
for i in range(X[0]):
    Count, Temp, Sum = 0, X[1], sum(Students[:i]) + Students[i]
    if Sum <= X[1]:print(0, end=" ")continue
    else:
        STemp = sorted(Students[:i], reverse=True)
        for j in range(i):
            if X[1] >= Sum:break
            Count, Sum = Count + 1, Sum - STemp[j]
    print(Count, end=" ")

# Come together for getting better !!!!


import bisect
n,m = map(int,raw_input().split())
a = map(int,raw_input().split())
A = []
for i in range(n):
	ac = a[:i]
	item = sum(ac) + a[i] - m
	ans = 0
	# print ac,item,a[i]
	while sum(ac) > (m - a[i]) and item>0:
		ix = bisect.bisect_left(a,item,0,i-1)
		item = sum(ac) + a[i] - m
		ac[ix] = 0
		ans+=1
		ac.sort()
	A.append(ans)
for i in A:
	print i,


# -*- coding: utf-8 -*-
# @Time : 2019/6/5 13:21
# @Author : yuggu
# @Site :
# @File : test.py
# @Software: PyCharm\

# import pymysql
# # 打开数据库连接，参数1：主机名或IP；参数2：用户名；参数3：密码；参数4：数据库名称
# db=pymysql.connect("localhost","root","root","school")
# # 使用cursor()方法创建一个游标对象cursor
# cursor=db.cursor()
# # 使用execute()方法执行sql查询
# cursor.execute("select version()")
# # 使用fetchone()
# data=cursor.fetchone()
# print("Data version:%s " % data)
# # 关闭数据库连接
# db.close()

# import sys
# import pygame
#
# charlotte=pygame.image.load("1.jpg")                   # 加载图片
# charlotterect=charlotte.get_rect()                     # 获取矩形区域
# size=(int(charlotterect[2]/3),int(charlotterect[3]/3)) # 这里把图片给缩小为原来的1/3
# charlotte=pygame.transform.scale(charlotte,size)       # 进行对原图片的缩小并返回一个缩小后图片的surface
#
# pygame.init()
# screen=pygame.display.set_mode(size)
# color=(0,0,0)
# charlotte=pygame.transform.scale(charlotte,size)
# charlotterect= (charlotte.get_rect())  # 获取矩形区域

# pygame.init()
# size=width,height=700,600
# screen=pygame.display.set_mode(size)
# color=(0,0,0)

# while True:
#     for event in pygame.event.get():
#          if event.type == pygame.KEYDOWN:
#              sys.exit()
#     screen.fill(color)
#     screen.blit(charlotte,charlotterect)
#     pygame.display.flip()
# pygame.quit()

#
# import urllib.request
# import urllib.parse
#
# data=bytes(urllib.parse.urlencode({'word':'hello'}),encoding='utf-8')
# response=urllib.request.urlopen("http://httpbin.org/post",data=data)
# html=response.read()
# print(html)

# import requests
# url='https://blog.csdn.net'
# # 创建头部信息
# headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0'}
# response=requests.get(url,headers=headers)
# print(response.content)

# # 爬虫爬取网页框架
# import requests
#
# def getHTMLText(url):
#     try:
#         r=requests.get(url,timeout=30)
#         r.raise_for_status() # 如果状态不是200，引发HTTPError异常,然后抛出捕获
#         # ,内部进行判断
#         r.encoding=r.apparent_encoding
#         return r.text
#     except:
#         return "产生异常"
#
# if __name__ == "__main__":
#     url="http://blog.csdn.net"
#     print(getHTMLText(url))
#
#
# # 浏览器headers模拟
# import requests
#
# kv={'User-Agent':'Mozilla/5.0'}
# response=requests.get('http://www.amazon.cn/',headers=kv)
# response.encoding=response.apparent_encoding
# print(response.request.headers)

# # 网络图片爬取
# import requests
# path='D://abc.jpg'  # 保存在D盘下，以abc.jpg命名
# url='https://wx4.sinaimg.cn/mw690/8d05b653ly1g4n0elm7axj20j60b475b.jpg'
#
# r=requests.get(url)
# print(r.encoding)
# with open(path,'wb') as f:
#     f.write(r.content)

# # 百度关键字提交接口
# import requests
# kv={'wd':'Python'}
# r=requests.get('http://www.baidu.com/s',params=kv)
# print(r.request.url)

# from bs4 import BeautifulSoup
# import urllib.request
# html = urllib.request.urlopen("https://www.csdn.net/").read().decode('utf-8')
# soup = BeautifulSoup(html,"html.parser")
# titles=soup.select("h3[class='company_name'] a") # CSS 选择器
# for title in titles:
# print(title.get_text(),title.get('href'))# 标签体、标签属性

# # 标签树向上遍历
# import requests
# from bs4 import BeautifulSoup
#
# url='https://python123.io/ws/demo.html'
# demo=requests.get(url).text
# soup=BeautifulSoup(demo,'html.parser')
# for parent in soup.a.parents:
# 	if parent is None:
# 		print(parent)
# 	else:
# 		print(parent.name)

# # 起点小说爬取
# import requests
# from bs4 import BeautifulSoup
# import bs4
#
#
# path="3.txt"
# fw=open(path,'w',encoding='utf-8')
#
# url = "https://book.qidian.com/info/1015323848#Catalog"
# r=requests.get(url,timeout=30)
# r.raise_for_status()
# r.encoding=r.apparent_encoding
#
# soup = BeautifulSoup(r.text, 'html.parser')
# for li in soup.find_all('ul')[3]:
#     if isinstance(li, bs4.element.Tag):
#         chapter = li.a
#         #print(chapter)
#         chapter_url = 'https:%s' % chapter.get('href')
#         #chapter_title=chapter.contents # ->['第一节 龙城']
#         chapter_title=chapter.text      # ->第一节 龙城
#         print(chapter_title)
#         print(chapter_url)
#         chapter_response=requests.get(chapter_url)
#         chapter_response.encoding=chapter_response.apparent_encoding
#         chapter_html=chapter_response.text
#         chapter_soup=BeautifulSoup(chapter_html,'html.parser')
#         chapter_tag=chapter_soup.find('div',class_='read-content j_readContent')
#         fw.write(chapter_title)
#         fw.write(chapter_tag.text)
#
# fw.close()
#
# import re
# import requests
#
#
# def getHtmlText(url):
#     try:
#         r = requests.get(url)
#         r.raise_for_status()
#         r.encoding = r.apparent_encoding
#         return r.text
#     except:
#         return ""
#
#
# def getInfor(html):
#     print(html)
#     print(re.findall(r'<tbody>.*?</tbody>', html))
#
#
# def main():
#     url = 'https://detail.tmall.com/item.htm?spm=a230r.1.14.41.7fab2157JOw8dn&id=555305762446&ns=1&abbucket=10'
#     html = getHtmlText(url)
#     getInfor(html)
#
#
# main()

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse = True)
    res = 0
    k = 100000000
    for i in range(n) :
        # print(i)
        k = max(min(k, a[i]),0)
        res += k
        k -= 1

    print(res)


size = int(input())
counts = [int(x) for x in input().split()]
counts.sort(reverse=True)
for i in range(1, size):
    if (counts[i]==counts[i-1]):
        counts[i] = counts[i] - 1
print(sum(counts)


n=raw_input()
l=raw_input().split()
l=map(x : int(x),l)
l=sorted(l)
s=set()
su=0
for i in l[::-1]:
    q=True
    for j in xrange(i, 0, -1):
        if not j in s and q:
            su+=j
            s.insert(j)
            q=False
print su


# -*- coding: utf-8 -*-
# @Time : 2019/6/5 13:21
# @Author : yuggu
# @Site :
# @File : test.py
# @Software: PyCharm\

# import pymysql
# # 打开数据库连接，参数1：主机名或IP；参数2：用户名；参数3：密码；参数4：数据库名称
# db=pymysql.connect("localhost","root","root","school")
# # 使用cursor()方法创建一个游标对象cursor
# cursor=db.cursor()
# # 使用execute()方法执行sql查询
# cursor.execute("select version()")
# # 使用fetchone()
# data=cursor.fetchone()
# print("Data version:%s " % data)
# # 关闭数据库连接
# db.close()

# import sys
# import pygame
#
# charlotte=pygame.image.load("1.jpg")                   # 加载图片
# charlotterect=charlotte.get_rect()                     # 获取矩形区域
# size=(int(charlotterect[2]/3),int(charlotterect[3]/3)) # 这里把图片给缩小为原来的1/3
# charlotte=pygame.transform.scale(charlotte,size)       # 进行对原图片的缩小并返回一个缩小后图片的surface
#
# pygame.init()
# screen=pygame.display.set_mode(size)
# color=(0,0,0)
# charlotte=pygame.transform.scale(charlotte,size)
# charlotterect= (charlotte.get_rect())  # 获取矩形区域

# pygame.init()
# size=width,height=700,600
# screen=pygame.display.set_mode(size)
# color=(0,0,0)

# while True:
#     for event in pygame.event.get():
#          if event.type == pygame.KEYDOWN:
#              sys.exit()
#     screen.fill(color)
#     screen.blit(charlotte,charlotterect)
#     pygame.display.flip()
# pygame.quit()

#
# import urllib.request
# import urllib.parse
#
# data=bytes(urllib.parse.urlencode({'word':'hello'}),encoding='utf-8')
# response=urllib.request.urlopen("http://httpbin.org/post",data=data)
# html=response.read()
# print(html)

# import requests
# url='https://blog.csdn.net'
# # 创建头部信息
# headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0'}
# response=requests.get(url,headers=headers)
# print(response.content)

# # 爬虫爬取网页框架
# import requests
#
# def getHTMLText(url):
#     try:
#         r=requests.get(url,timeout=30)
#         r.raise_for_status() # 如果状态不是200，引发HTTPError异常,然后抛出捕获
#         # ,内部进行判断
#         r.encoding=r.apparent_encoding
#         return r.text
#     except:
#         return "产生异常"
#
# if __name__ == "__main__":
#     url="http://blog.csdn.net"
#     print(getHTMLText(url))
#
#
# # 浏览器headers模拟
# import requests
#
# kv={'User-Agent':'Mozilla/5.0'}
# response=requests.get('http://www.amazon.cn/',headers=kv)
# response.encoding=response.apparent_encoding
# print(response.request.headers)

# # 网络图片爬取
# import requests
# path='D://abc.jpg'  # 保存在D盘下，以abc.jpg命名
# url='https://wx4.sinaimg.cn/mw690/8d05b653ly1g4n0elm7axj20j60b475b.jpg'
#
# r=requests.get(url)
# print(r.encoding)
# with open(path,'wb') as f:
#     f.write(r.content)

# # 百度关键字提交接口
# import requests
# kv={'wd':'Python'}
# r=requests.get('http://www.baidu.com/s',params=kv)
# print(r.request.url)

# from bs4 import BeautifulSoup
# import urllib.request
# html = urllib.request.urlopen("https://www.csdn.net/").read().decode('utf-8')
# soup = BeautifulSoup(html,"html.parser")
# titles=soup.select("h3[class='company_name'] a") # CSS 选择器
# for title in titles:
# print(title.get_text(),title.get('href'))# 标签体、标签属性

# # 标签树向上遍历
# import requests
# from bs4 import BeautifulSoup
#
# url='https://python123.io/ws/demo.html'
# demo=requests.get(url).text
# soup=BeautifulSoup(demo,'html.parser')
# for parent in soup.a.parents:
# 	if parent is None:
# 		print(parent)
# 	else:
# 		print(parent.name)

# # 起点小说爬取
# import requests
# from bs4 import BeautifulSoup
# import bs4
#
#
# path="3.txt"
# fw=open(path,'w',encoding='utf-8')
#
# url = "https://book.qidian.com/info/1015323848#Catalog"
# r=requests.get(url,timeout=30)
# r.raise_for_status()
# r.encoding=r.apparent_encoding
#
# soup = BeautifulSoup(r.text, 'html.parser')
# for li in soup.find_all('ul')[3]:
#     if isinstance(li, bs4.element.Tag):
#         chapter = li.a
#         #print(chapter)
#         chapter_url = 'https:%s' % chapter.get('href')
#         #chapter_title=chapter.contents # ->['第一节 龙城']
#         chapter_title=chapter.text      # ->第一节 龙城
#         print(chapter_title)
#         print(chapter_url)
#         chapter_response=requests.get(chapter_url)
#         chapter_response.encoding=chapter_response.apparent_encoding
#         chapter_html=chapter_response.text
#         chapter_soup=BeautifulSoup(chapter_html,'html.parser')
#         chapter_tag=chapter_soup.find('div',class_='read-content j_readContent')
#         fw.write(chapter_title)
#         fw.write(chapter_tag.text)
#
# fw.close()
#
# import re
# import requests
#
#
# def getHtmlText(url):
#     try:
#         r = requests.get(url)
#         r.raise_for_status()
#         r.encoding = r.apparent_encoding
#         return r.text
#     except:
#         return ""
#
#
# def getInfor(html):
#     print(html)
#     print(re.findall(r'<tbody>.*?</tbody>', html))
#
#
# def main():
#     url = 'https://detail.tmall.com/item.htm?spm=a230r.1.14.41.7fab2157JOw8dn&id=555305762446&ns=1&abbucket=10'
#     html = getHtmlText(url)
#     getInfor(html)
#
#
# main()

n = int(input())
a = sorted(map(int, input().split()),reverse = True)
res = 0
k = 100000000
for i in a :
    k = max(min(k, i),0)
    res += k
    k -= 1
print(res)


n = int(input())
a = list(input())
t=0
g =a.count("?")
if g==0:
	print("No")
	exit()

for i in range(n-1):
	j = i+1
	if (a[i]==a[j] and a[i]!="?") :
		print("No")
		exit()
for i in range(1,n-2):
	if a[i-1]!=a[i+1] and a[i]=="?" and (a[i-1]!="?" and a[i+1]!="?" ):
		t+=1

if t=<g and t!=0:
	print("no")
	exit()
print("Yes")


#include <iostream>
#include <vector>

using namespace std;

const int SIG = 26;

int n, m;
vector<string> mat;

vector<int> cnt_f(const int d) {
    vector<int> cnt(SIG);
    for (int i = n - 1 - d, j = n - 1; i < n; i++, j--) {
        cnt[mat[i][j] - 'a']++;
    }
    return cnt;
}

int main() {
    ios_base::sync_with_stdio(0);

    cin >> n >> m;
    mat.resize(n);
    for (auto &s : mat) cin >> s;

    vector<ll> dp(1), dp_prev;

}


x=int(input())
string=input()
i=0
counter=0
right=-1
left=0
counterik=0
if string.count('MM')>=1 or string.count('CC')>=1 or string.count('YY')>=1:
    print("NO")
else:
    while i<x:
        right=string[i+1]
        if i==0 and string[i]!='?':
            left=string[i]
            i+=1
            continue
        elif i==x-1:
            if string[-1]=='?':
                counter+=2
            break
        if string[i]=='?':
            if left==right:
                counter+=2
                break
            else:
                counter+=1
                counterik+=1
            if string[i+1]=='?':
                pass
            else:
                left=string[i+1]
        else:
            left=string[i]
        i+=1
    if counterik==string.count('?'):
        print("NO")
    else
        if counter>=2:
            print("YES")
        else:
            print("NO")


    import sys
n = int(input())
lst = list(input())
s=0
z=0
#print(len(lst))
lst1 = ["C", "Y", "M"]
n=0
for i in range(len(lst)-1):
    if lst[i]=="?":
        n+=1
for i in range(len(lst)-1):
    if lst[i]=='?':
        s+=1
        if i==0:
            s+=1
        elif i==len(lst)-1:
            s+=1
        elif i>0 and i<len(lst)-1:
            if lst[i-1]==lst[i+1]:
                s+=1
            else:
                z+=2
                s+=1
    if lst[i]==lst[i+1]:
        z=1
#print(z,s)
if s!=0:
    if z%s==0 and z!=0:
        print('No')
        sys.exit()
    elif z%s==1:
        print('No')
        sys.exit()
if n==len(lst)-1:
    print("Yes")
elif z==1:
    print("No")
elif s==0:
    print("Yes")
else:
    print("Yes")


n = int(input())
a = list(input())

for i in range(n-1):
	j = i+1
	if (a[i]==a[j] and a[i]!="?") or (a[min(0,i-1)]!=a[j] and a[min(0,i-1)]!=a[min(n-1,j+1)]:
		print("No")
		exit()

print("Yes")


from fractions import Fraction as f
inps = list(map(int,input().split()))
a,b,c,d = inps[0],inps[1],inps[2],inps[3]
 if (a/b < c/d): print(f((b*c)-(a*d),b*c))
elif (a/b > c/d): print(f((a*d)-(b*c),a*d))
else: print("0/1")


from fractions import Fraction
a,b,c,d=raw_input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
if c>=a and d>=b:
	if a>b:
		if c>=d
			print Fraction(c*b-d*a,c*b)
		else:
			print Fraction(d*a-c*b,d*a)
	elif a==b:
		if c>=d:
			print Fraction(c-d,c)
		else:
			print Fraction(d-c,d)

	else:
		if c<d:
			print Fraction(d*a-c*b,d*a)
		else:
			print Fraction(c*b-d*a,c*b)

elif c>=a and d<b:
	print Fraction(c*b-d*a,c*b)
elif c<a and d<b:
	if a>b:
		if c>=d:
			print Fraction(c*b-d*a,c*b)
		else:
			print Fraction(d*a-c*b,d*a)
	elif a==b:
		if c>=d:
			print Fraction(c-d,c)
		else:
			print Fraction(d-c,d)
	else:
		if c<d:
			print Fraction(d*a-c*b,d*a)
		else:
			print Fraction(c*b-d*a,c*b)
elif c<a and d>=b:
	print Fraction(d*a-c*b,d*a)


__author__ = 'vasiliy.lomanov'

src = raw_input().split()

a = float(src[0])
b = float(src[1])
c = float(src[2])
d = float(src[3])

def Euclid(a, b):
    q = a/b
    r = a - q*b
    if r == 0:
        return b
    else:
        return Euclid(b, r)

k = min(b/d, a/c)

if b/d < a/c:
    x = a*d
    y = a*d-c*b
else:
    x = c*b
    y = c*b - a*d

nod = Euclid(x, y)
print str( int(y/nod) ) + "/" + str( int(x/nod) )


import sys

hulp=sys.stdin.readline().split()

n,m=int(hulp[0]),int(hulp[1])

f=[int(x) for x in sys.stdin.readline().split()]

f.sort()
mindif=1000

for x in range(m-n+1):
    mindif=min(f[x+n-1]-f[x],mindif)

print mindif


"""
    Template written to be used by Python Programmers.
    Use at your own risk!!!!
    Owned by adi0311(rating - 5 star at CodeChef and Specialist at Codeforces).
"""
import sys
import heapq
from math import *
from collections import defaultdict as dd  # defaultdict(<datatype>) Free of KeyError.
from collections import deque  # deque(list) append(), appendleft(), pop(), popleft() - O(1)
from collections import Counter as c  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var): sys.stdout.write(var)
def l(): return list(map(int, data().split()))
def sl(): return list(map(str, data().split()))
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [[val for i in range(n)] for j in range(m)]

def first():
    global a, b, e, d
    div, mul = e, a
    a1, a2 = e*mul, a*mul
    if a2 / div > b:
        return mod, 1
    return a*b*e-d*a*a, div

def second():
    global a, b, e, d
    div, mul = d, b
    a1, a2 = e * mul, d * mul
    if a1 / div > a:
        return mod, 1
    return d*a*b-e*b*b, div

a, b, e, d = sp()
t1 = first()
t2 = second()
if t1[0]/t1[1] < t2[0]/t2[1]:
    diff, area = t1[0], a * b * t1[1]
else:
    diff, area = t2[0], a * b * t2[1]
g = gcd(diff, area)
out(str(diff//g)+"/"+str(area//g))


def FindDirection(start, end, n):
	modelTab = ['v', '<', '^', '>']
	iStart = 0
	iEnd = 0
	for i in range(4):
		if start == modelTab[i]:
			iStart = i
		if end == modelTab[i]:
			iEnd = i
	if (n%4) == 2 or (n%4) == 4:
		return 'undefined'
	elif ((n%4) == 1 and (iEnd-iStart)%4 == 1) or ((n%4) == 3 and (iEnd-iStart)%4 == 3):
		return 'cw'
	elif: ((n%4) == 1 and (iEnd-iStart)%4 == 3) or ((n%4) == 3 and (iEnd-iStart)%4 == 1):
		return 'ccw'
	else:
		return 'undefined'

def read_str():
	return map(str, raw_input().split(' '))

start, end = read_str()
n = map(int, raw_input().split(' '))[0]

print (FindDirection(start, end, n))


 a='v<^>'
q,w=(str(i) for i in input().split())
k=int(input())%4
a1=a.find(q)
a2=a.find(w)
f1=False
f2=False
f3=False
f4=False
If (a1==a2) and (k==0):
    print('undefined')
else:
    if a1<=a2:
        if abs(a2-a1)==k:
            f1=True
        if 4-abs(a2-a1)==k:
            f2=True
    else:
        if a1-a2==k:
            f3=True
        if 4-a1+a2==k:
            f4=True
    if ((f1) and (f2)) or ((f3) and (f4)):
        print('undefined')
    elif (f1) or (f4):
        print('cw')
    elif (f2) or(f3):
        print('ccw')


 a='v<^>'
q,w=(str(i) for i in input().split())
k=int(input())%4
a1=a.find(q)
a2=a.find(w)
f1=False
f2=False
f3=False
f4=False
if a1<=a2:
    if abs(a2-a1)==k:
        f1=True
    if 4-abs(a2-a1)==k:
        f2=True
else:
    if a1-a2==k:
        f3=True
    if 4-a1+a2==k:
        f4=True
if ((f1) and (f2)) or ((f3) and (f4)):
    print('undefined')
elif (f1) or (f4):
    print('cw')
elif (f2) or(f3):
    print('ccw')


f=[0]*99
q=0
a,b,c=map(int,input().split())
for i in range(a):s=input()
    for j in range(b):
        if s[j]=='Y':f[j]+=1
            if f[j]==c:q+=1
#kitten
print q


#include<cstdio>

int main()
{
    int n, m, k, c[16]={0}, ans=0;
    scanf("%d%d%d", &n, &m, &k);

    for(int i=0; i<n; i++)
    {
        char s[16], cnt=0;
        scanf("%s", s);

        for(int j=0; j<m; j++)
            if( s[j]=='Y' )
                cnt++;

        if( cnt>=k )
            ans++;
    }

    printf("%d\n", ans);
}


n, m, k = tuple(map(int, input().split(' ')))
    marks = [0 for i in range(m)]
    for i in range(n):
        s = input()
        for j in range(m):
            if s[j] == 'Y':
                marks[j] += 1
    res = 0
    for mark in marks:
        if mark >= k:
            res += 1
print(res)


f,q=[0]*99,0
a,b,c=map(int,input().split())
for i in range(a):
    s=input()
    for j in range(b):
        if s[j]=='Y':f[j]+=1
            if f[j]==c:q+=1
print(q)#kitten


#include<bits/stdc++.h>
using namespace std;
const int inf = 1000000001;
const int MOD = 1000000007;
typedef long long Int;
#define FOR(i,a,b) for(int i=(a); i<=(b);++i)
#define mp make_pair
#define pb push_back
#define sz(s) (int)((s).size())

int n;
int a[111][111];

void go() {
    int id=0, i=0, j=0;
    lab:;
    j=id%n;
    i=id/n;
    cin>>a[i][j];
    id++;
    //(id==n*n ? (goto here) : (goto lab));
    here:;
}

int cnt[111];

int main() {
    //freopen("input.txt", "r", stdin);//freopen("output.txt", "w", stdout);
    //cin>>n;
    //go();
    //cout<<a[2][1]<<endl;
    int n,m,f;
    scanf("%d %d %d\n",&n,&m,&f);
    int ans=0;
    FOR(it,1,n) {
        string s;getline(cin, s);
        int cur=0;
        int t=m;
        FOR(j,0,sz(s)-1) if(s[j]=='Y' || s[j]=='N') {
            cnt[t] += (s[j]=='Y');
            t--;
            if(t==0) break;
        }

    }
    FOR(i,1,m) ans += (cnt[i]>=f);
    cout<<ans<<endl;
}


d = {'q':-9,'r':-5,'b':-3,'n':-3,'p':-1,
    'Q':9,'R':5,'B':3,'N':3,'P':1}

t = sum(sum((d[c] if c in d else 0) for c in raw_input()) for x in range(8))
print ("White" if t > 0 else ("Black" if t < 0 else "Draw")


c={'q':9, 'r':5, 'b':3, 'n':3, 'p':1, 'k':0, '.':0}
r=[0, 0]
for i in range(8):
    r=map(sum, zip(r, *map(lambda s:  [0,0] if s=='.' else s.isupper() * [0] + [c[s.lower()]] + s.islower() * [0], raw_input())))
if r[1] > r[0]:
    print 'White'
else if r[1] == r[0]:
    print 'Draw'
else:
    print 'Black'


a,w,b='',0,0
for i in range(8):a+=input()
w,b=9*a.count('Q')+5*a.count('R')+3*a.count('B')+3*a.count('N')+a.count('P'),9*a.count('q')+5*a.count('r')+3*a.count('b')+3*a.count('n')+a.count('p');print('White' if w>b else 'Black' if w<b else 'Draw')
→Judgement Protocol


white = {"Q": 9, "R": 5, "B": 3, "N": 3"P": 1}
black = {"q": 9, "r": 5, "b": 3, "n": 3, "p": 1}
white_score = black_score = 0
for i in range(8):
    line = input()
    for j in range(8):
        if line[j] in black:
            black_score += black[line[j]]
        elif line[j] in white:
            black_score += white[line[j]]

if black_score > white_score:
    print("Black")
elif white_score > black_score:
    print("White")
else:
    print("Draw")


n, k, m, d = map(int, input().split())
ans = 0
for i in range(1, d + 1):
    x = min(n // ((i - 1) * k + 1), m)
    if (x && (n // x + k - 1) // k == i):
        ans = max(ans, x * i);
print(ans)


#include <bits/stdc++.h>

using namespace std;

const int NMAX = 100;

typedef long long I64;

bool overf(I64 a, I64 b)
{
    I64 x = a * b;
    x = a * b;
    if (a != 0 && x / a != b)
        return 1;
    return 0;
}

int main()
{
    I64 N, K, D, M;
    I64 best = 0;
    cin >> N >> K >> M >> D;
    for( int ture = 1;  ture <= D;  ++ture ) {
        I64 bomb = N / (1 + (ture - 1) * K);
        if( overf(ture - 1, K) )
            bomb = 0;
        bomb = min(bomb, M);
        best = max(best, ture * bomb);
    }
    cout << best << '\n';
    return 0;
}


n, k, m, d = map(int, input().split())
ans = 0
for i in range(1, d+1):
    hi = min(m, n//(k*(i-1)+1), lo = n//(k*i+1)
    if(hi > lo) ans = max(ans, i*hi)
print(ans)


n, k, M, D = map(int, input().split())
ans = 0
for i in range(1, D+1):
	l = n//(i*k)
	r = n//((i-1)*k + 1)
    if l <= M:
        ans = max(ans, min(M, r)*i)
print(ans)


n, k, M, D = map(int, input().split())

ans = 0
for i in range(1, D+1):
	l = n//(i*k)
	r = n//((i-1)*k + 1)

    if l <= M:
        ans = max(ans, min(M, r))

print(ans)


Integer = int(input(""))
if Integer < 100 and Integer > 0:
    import math
    First_dig = math.floor(Integer/10)
    Second_dig = Integer - First_dig * 10
    if First_dig == 0:
        n = 2
    elif First_dig == 1:
        n = 7
    elif First_dig == 2:
        n = 2
    elif First_dig == 3:
        n = 3
    elif First_dig == 4:
        n = 3
    elif First_dig == 5:
        n = 3
    elif First_dig == 6:
        n = 2
    elif First_dig == 7:
        n =5
   elif First_dig == 8:
        n = 1
    elif First_dig == 9:
        n = 2

    if Second_dig == 0 :
        k = 2
    elif Second_dig == 1:
        k = 7
    elif Second_dig == 2:
        k = 2
    elif Second_dig == 3:
        k = 3
    elif Second_dig == 4:
        k = 3
    elif Second_dig == 5:
        k = 3
    elif Second_dig == 6:
        k = 2
    elif Second_dig == 7:
        k = 5
    elif Second_dig == 8:
        k = 1
    else:
        k = 2

print(k*n)


n=int(raw_input())
a=int(raw_input())
b=int(raw_input())
c=int(raw_input())
x=n/a
if ((n%a)-c)>0:
    x+=((n%a)-c)/(b-c))
y=(n-c)/(b-c)+(((n-c)%(b-c))/a)
print max(x,y)


l=lambda:input()
n,a,b,c=l(),l(),l(),l()
if a<=(b-c):print n/a
else:g = 0;if n>b: g+=(n-с)/(b-c);n-=(b-c)*g;g += n/a;print g


d = int(raw_input())
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())

if(a == 1000000000000000000):
  qntd = 999999999999999995
else if(a <= (b - c)):
  qntd = d / a
else :
  if(d >= b):
    qntd = (d - c) / (b - c)
  else :
    qntd = 0

print (qntd)


n = int(input())
a = int(input())
b = int(input())
c = int(input())

_b = int(b);
b -= c

t = 0
if(n >= b) t = 1

print(max(n // a, (n - _b) // b + max(t, ((n - _b) % n + _b) // a)))


from math import ceil
n= int(input())
a = int(input())
b = int(input())
c = int(input())
if b - c < a:
    if n < b:
        if n < a:
            print(0)
        else:
             print(n // a)
    else:
        if b > 100000000000000000:
            count = n // (b - c) + 1 - b // (b - c)
        else:
            if b // ( b - c) * (b - c) + n % (b - c) >= b:
                count = n // (b - c) + 1  - (b // ( b - c) * (b - c) + n % (b - c)) // (b - c)
            else:
                count = n // (b - c) + 1  - (b // ( b - c) + 1) * (b - c) + n % (b - c)) // (b - c)
        if a <= b:
            if a < n:
                print(count + (n - (b - c) * count) // a)
            else:
                print(count)
        else:
            print(count)
else:
    if n < a:
        print(0)
    else:
        print(n // a)


x,y,z=map(int,input().split())
if (x-(y+z))*((x+z)-y)<0:
    print('?)
else:
    if x-(y+z)>0:
        print('+')
    elif (x+z)-y<0:
        print('-')
    else:
        print('0')


By SKhan, contest: Codeforces Round #564 (Div. 2), problem: (A) Nauuo and Votes, Wrong answer on pretest 5, #

x, y, z = map(int, input().split(" "))

if (z >= x and z >= y) and z >= x + y:
    print("?")
elif x > y and x >= z:
    print("+")
elif y > x and y >= z:
    print("-")
else:
    print("0")


a = str(input())
b = []
b = a.split()
x = int(b[0])
y = int(b[1])
z = int(b[2])

if x == y and z == 0:
    print('0')
if x == 0 and y == 0 and z > 0:
    print('?')
if x + z > y:
    print('+')
if y + z > x
    print('-')
else:
    print('?')


while True:
    try:
        arr = list(map(int,input().split()))
        # print(arr)
        m = max(arr)
        if m == arr[0]:
            print('+')
        elif m == arr[1]:
            print('-')
        elif arr[1] == arr[0] and arr[0] == m:
            print('0')
        elif:
            print('?')
    except EOFError:
        break

    except ValueError:
        break


x, y, z = map(int, input().split())

if x == y == z ==0:
    print('0')
elif abs(x-y) > z:
    if x > y:
        print('+')
    elif x < y:
        print('-')
    else:
        print('0')
elif abs(x -y) ==z:
    if not z:
        print('0')
    else:
        print('?’)
else:
    print('?')


a,b=map(int,input().split())
if a==b:
    print("1/1")
elif a==6 or b==6:
    print("0/1")
else:
    maxx=max(a,b)
    maxx=(6-maxx)+1
    if 6%maxx=0:
        a=6//maxx
        print("1/str(a)")
    else:
        print("str(maxx)/6")


list=raw_input().split()
x=max(int(list[0]),int(list[1]))
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
a=6-x+1
b=6
print '%d/%d' % (a/gcd(a,b),b/gcd(a,b))


W,Y=[i for i in input().split(" ")]
Z=max(W,Y)
num=(7-Z)
if num%6==0:
    print("1/1")
elif num%3==0:
    print("%s/2",%(num/3))
else num%2==0:
    print("%s/3",%(num/2))


def dice(Y,W) :
	a = 7-max(Y,W)
	from fractions import *
	c = Fraction(a/6)
	return 'c'
Y = int(input())
W = int(input())


n=int(input())
import sys
num9=len(str(2*n))-1

s=[str(i) for i in range(10)]
ans=0

if(num9==0):
    print(n*(n-1)//2)
    sys.exit()
for i in s:
    x=i+'9'*num9
    x=int(x)
    ans+=max(0,min((n-x//2),x//2))
print(ans)


n=int(input())
s0=str(n+n-1)
k=len(s0)
if s0!=k*'9':
    k-=1
s=k*'9'
def cnt(s):
    v=int(s)
    #print(v)
    if v>n*2-1:
        return 0
    if v==2*n-1:
        return 1
    if v>n:
        return n-v//2
    if v<=n:
        return v//2
ans=cnt(s)
for i in range(1,9):
    ans+=cnt(str(i)+s)
print(ans)


import sys
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')

n = input()
x = int('9'*len(str(n)))
max_val = 2*n - 1
if n < 5:
	print (n*(n-1))/2
elif max_val < x:
	x /= 10
	y = pow(10,len(str(n))-1)
	z = y/10
	ans = 0
	while x <= max_val:
		a = x/2 + 1
		ans += min(n,x-1) - a + 1
		x += y
	print ans
elif x == n:
	print n-x/2-1
else:
	print n-x/2


from math import log10, floor

n = int(input())

base = floor(log10(n//5)) + 1

nines = sum(9*10**i for i in range(base))

result = 0

for i in range(4):
	target = nines*(i+1) + i
	if target//2 < n < target:
		result += n - target//2
	if n >= target:
		result += target // 2

print(result)


import sys

lines = []
for line in sys.stdin:
    lines.append(line)

n = int(lines[0].rstrip("\r\n\t "))

max_price = n * 2 - 1
nines = 0
mp = max_price
while mp >= 9:
    nines += 1
    mp = int(mp / 10)
if nines < 1:
    print("0")
    exit()
price_suffix = "9"*nines

pairs = set()
def add_pairs(max_x: int, price: int):
    from_max = int(price / 2)
    to_min = from_max + 1
    to_max = price - 1
    if to_max > max_x:
        to_max = max_x
    from_min = price - to_max
    for x in range(from_min, from_max + 1):
        pairs.add(str(x) + ':' + str(price - x))

cnt = 0
for d in range(0, 10):
    if d > 0:
        price = int(str(d) + price_suffix)
    else:
        price = int(price_suffix)
    if price <= max_price:
        add_pairs(n, price)

print(len(pairs))


import math
n = int(input())
if n <= 2:
    print(n+1)
    exit()
sqr = math.sqrt(n)
if sqr == int(sqr):
    print(int(sqr+sqr))
    exit()
else:
    if n % 2 == 1:
        n += 1
    test = math.sqrt(n+1)
    if test == int(test):
        print(test+test)
        exit()
    sqr = math.ceil(math.sqrt(n))
    for i in range(sqr, 1, -1):
        if n % i == 0:
            opt = i + n//i
    n += 1
    sqr = math.ceil(math.sqrt(n))
    for i in range(sqr, 1, -1):
        if n % i == 0:
            opt2 = i + n//i
    print(min(opt, opt2))


g = input()

ans = 2

i = 1

h = []

c = 2

n = 1

g1 = g

if g == 1:

	g = g + 3

while i < g:

	if i == 1:
		i = i + 1

		continue

	k = int(len(h)**(0.5))

	if k**2 == len(h) and (k != 1 and k != 0):

		n = n + 1

	j = 1

	while j <= n:

		h.append(i)

		j = j + 1

	l = int((len(h)+1)**(0.5))

	if l**2 == len(h)+1:

		h.append(i)

	i = i + 1

g = g1

print h[g-1]


num i = int(input())
if(i<4):
    print(i+1)
else:
    print(4)


n = int(input())
sqrt = int(n ** (1/2))
2x = sqrt * sqrt
r = None

if not n - 2x:
    r = 2 * sqrt
elif n - 2x > sqrt:
    r = 2 * sqrt + 1
r = 2 * sqrt + 2
print(r)


n = int(input())
if(n<=3):
    print(n+1)
else:
    a = n**0.5
    d = a-int(a)
    if(d>=0.5):
        a = int(a)+1
        print(2*a)
    else if(d>0 and d<0.5):
        a = int(a)
        print(2*a+1)
    else:
        a = int(a)
        print(2*a)


n,m,k=map(int,str(raw_input()).split())
mod=10**9+7
if n>m:
    n,m=m,n
if k==-1 and n+m%2==1:
    print 0
except:
    print pow(2,((n-1)*(m-1)),mod)


def power(x, y, z):
    number = 1
    while y:
        if y & 1:
            number = number * x % z
        y >>= 1
        x = x * x % z
    return number

n, m, k = map(int, raw_input().split())
mod = (10**9) + 7;
print power(2, (n - 1) * (m - 1), mod)


#include "bits/stdc++.h"
#define lpa(i,a,b) for(int i=a; i<b; ++i)
#define lp(i,n) lpa(i,0,n)
typedef long long ll;
using namespace std;
ll modexp(ll num,ll power,ll mod)
{
    ll res=1;
    while(power)
    {
        if(power%2) res=(res*num)%mod;
        num=(num*num)%mod;
        power/=2;
    }
    return res;
}

int main()
{
    ll n,m,k;
    cin>>n>>m>>k;
    if(n%2!=m%2 && k!=1) cout<<0;
    else
    {
        ll mod=pow(10,9)+7;
        n--;
        m--;
        n%=mod-1;
        m%=mod-1;
        cout<<modexp(2,n*m,mod);
    }
}


m, n, k = map(int, input().split())
mod = 10**9+7
def powermod(x,y):
  res = 1
  while(y>0):
    if y&1:
      res=res*x%mod
    x=x*x%mod
    y=y»1
  return res

if (m%2 != n%2 and k == -1):
  print (0)
else:
  print (powermod(2, (m-1)*(n-1)))


def shift(sequence,shift):
    keyboard = "qwertyuiopasdfghjkl;zxcvbnm,./"
    keyboardList = list(keyboard)
    sentence = ""
    if shift == "R"
        for i in sequence:
            sentence+=keyboardList[keyboardList.index(i)-1]
        return sentence
    for i in sequence:
        sentence+=keyboardList[keyboardList.index(i)+1]
    return sentence
direction = str(input())
sequence = str(input())
print (shift(sequence))


x=raw_input()
y=raw_input()
i=1
if x=="R":
    i*=-1
key = "qwertyuiopasdfghjkl;zxcvbnm,./"
s=""
for m in y:
    s+=key[key.index(m)+i]:
print s


verh='qwertyuiop'
centr='asdfghjkl;'
niz='zxcvbnm,./'
n=input()
a=input()
nomervstroke=0##нужныйИндексВ строке
if n=="R":##если нажал правее
    for i in range(len(a)):
        if a[i] in verh:
            nomervstroke=verh.find(a[i])-1
            print(verh[nomervstroke],end='')
        elif a[i] in centr:
            nomervstroke=centr.find(a[i])-1
            print(centr[nomervstroke],end='')
        else:
            nomervstroke=niz.find(a[i])-1
            print(niz[nomervstroke],end='')
else:##если нажал левее
    for i in range(len(a)):
        if a[i] in verh:
            nomervstroke=verh.find(a[i])+1
            print(verh[nomervstroke],end='')
        elif a[i] in verh:
            nomervstroke=centr.find(a[i])+1
            print(centr[nomervstroke],end='')
        else:
            nomervstroke=niz.find(a[i])+1
            print(niz[nomervstroke],end='')


n=input()
m=list(input())
a='qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./' #特殊的\'符号前面加\表示就是这个符号
print(l)
if n=='R':
    for i in range(len(m)):
        c=a.find(m[i])
        m[i]=l[c-1]
else:
    for i in range(len(m)):
        c=a.find(m[i])
        m[i]=l[c+1]
print(''.join(m))


verh='qwertyuiop'
centr='asdfghjkl;'
niz='zxcvbnm,./'
n=input()
a=input()
nomervstroke=0##нужныйИндексВ строке
if n=="R":##если нажал правее
    for i in range(len(a)):
        if a[i] in verh:
            nomervstroke=verh.find(a[i])-1
            print(verh[nomervstroke],end='')
        elif a[i] in centr:
            nomervstroke=centr.find(a[i])-1
            print(centr[nomervstroke],end='')
        else:
            nomervstroke=niz.find(a[i])-1
            print(niz[nomervstroke],end='')
else:##если нажал левее
    for i in range(len(a)):
        if a[i] in verh:
            nomervstroke=verh.find(a[i])+1
            print(verh[nomervstroke],end='')
        elif a[i] in centr:
            nomervstroke=centr.find(a[i])+1
            print(centr[nomervstroke],end='')
        else:
            nomervstroke=niz.find(a[i])+1
            print(niz[nomervstroke],end='')


def check(i,j,matrix) :
    c = []
    if i+4<10 :
        s= ""
        s = matrix[i][j] + matrix[i+1][j] + matrix[i+2][j] + matrix[i+3][j] + matrix[i+4][j]
        c.append(s)
        if j+4<10 :
            t = ""
            t = matrix[i][j] + matrix[i+1][j+1] + matrix[i+2][j+2] + matrix[i+3][j+3] + matrix[i+4][j+4]
            c.append(t)
    if j+4<10 :
        s = ""
        s = matrix[i][j] + matrix[i][j+1] + matrix[i][j+2] + matrix[i][j+3] + matrix[i][j+4]
        c.append(s)
    for i in range(len(c)):
        if c[i]=='XX.XX' or c[i]=='.XXXX' or c[i]=='X.XXX' or c[i] == 'XXX.X' or c[i]=='XXXX.':
            return True
            break
    else :
        return False

matrix = []
for i in range(10):
    s = raw_input()
    matrix.append(s)
flag = 0
for i in range(10):
    for j in range(10):
        if matrix[i][j]=='X' or matrix[i][j]=='.' :
            if check(i,j,matrix) :
                print "YES"
                flag = 1
                break
    if flag == 1 :
        break
else :
    print "NO"


b = [['.' for c in range(10)] for y in range(10)]

for x in range (10):
    tmp = raw_input()
    for y in range(10):
        b[x][y] = tmp[y]
        if b[x][y] == '.':
            b[x][y] = 'c'

for x in range(10):
    for y in range(6):
        tmp = 0
        check= False
        if b[x][y] == 'X':
            for c in range(5):
                if b[x][y+c] in "Xc":
                    if b[x][y+c] == 'c':
                        if(check):
                            tmp = 0
                            break
                        check = True
                    tmp+=1
            if tmp == 5:
                print "YES"
                exit()
for y in range(10):
    for x in range(6):
        tmp = 0
        check= False
        if b[x][y] == 'X':
            for c in range(5):
                if b[x+c][y] in "Xc":
                    if b[x+c][y] in 'c':
                        if(check):
                            tmp = 0
                            break
                        check = True
                    tmp+=1
            if tmp == 5:
                print "YES"
                exit()

for y in range(6):
    for x in range(6):
        tmp = 0
        check= False
        if b[x][y] == 'X':
            for c in range(5):
                if b[x+c][y+c] in "Xc":
                    if b[x+c][y+c] in 'c':
                        if(check):
                            tmp = 0
                            break
                        check = True
                    tmp+=1
            if tmp == 5:
                print "YES"
                exit()

for y in xrange(4,10):
    for x in range(6):
        tmp = 0
        check= False
        if b[x][y] == 'X':
            for c in range(5):
                if b[x+c][y-c] in "Xc":
                    if b[x+c][y-c] in 'c':
                        if(check):
                            tmp = 0
                            break
                        check = True
                    tmp+=1

            if tmp == 5:
                print "YES"
                exit()

print "NO"


f = list(map(int, input().split()))
w = f[0]
h = f[1]
n = f[2]
s = 0
d = 2
for i in range(n):
s = s + (w + h - d)*2
d = d + 8
print(s)


w,h,k = map(int,input().split())
s = 0
for i in range(k):
	s += ((w+h)*2)-4
	w-=
	h-=4
print(s)


def zadanie1(w,h,k):
    i=2
    while k!+0:
        if i%2==0:
            summarise+=(w+h)*2
            w-=2
            k-=2
            i+=1
        else:
            i+=1
    return summarise
w,h,k=map(int,input().split())
summarise=0
print(zadanie1(w,h,k))


N,K,X = map(int,input().split())
lst = sorted([int(i) for i in input().split()])

total = 0

for i in range(K):
    total += lst[i] + X
print(total)


from sys import stdin
n,k,x = map(int,stdin.readline().split())
a = map(int,stdin.readline().split())
print sum(a[:k])+k*x


#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int x[n],y[n];
	map<int,int> mp;
	for(int i = 0;i<n;i++)
	{
		cin >> x[i];
		mp.insert({x[i],1});
	}
	for(int i = 0;i<n;i++)
	{
		cin >> y[i];
		mp.insert({y[i],1});
	}

	int cnt = 0;
	for(int i = 0;i<n;i++)
	{
		for(int j =0 ;j<n;j++)
		{
			if(mp.find(x[i]^y[j]) != mp.end())
				cnt++;
		}
	}

	if(cnt&1)
		cout << "Koyomi" << endl;
	else
		cout << "Karen" << endl;
	return 0;
}


n,k,x=map(int,input().split())
a=list(map(int,input().split()))
if(len(a))<=2:
    print(k*x)
else:
     a.remove(max(a))
      a.remove(max(a))
     print(sum(a)+k*x)


#
 n,k,x=[int(x) for x in input().split()]
a =[int(x) for x in input().split()]
sum = 0
for i in range(len(a)-k):
        sum = sum + a[i]
print (sum + k*x)


#include <bits/stdc++.h>

using namespace std;

int main(){
    long long int n;
    int div = 0, tot=0;

    cin >> n;

    for(int i=2;i<n;i++){
        for(int j=2;j<=10;j++){
            if(i%j==0)
                div++;
            else
                continue;
            if(div==9)
                tot++;
                break;
        }
    }
    cout << tot << endl;

}
// 1537624596591


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

void
main()
{

   int i,qtd=0;
  long long int num;

   scanf("%lld",&num);

   fprintf(stdout,"1\n");

}
// 1537626298292


#include <iostream>
#include <vector>

int main(){

    const int64_t D = (2 * 2 * 2) * (3 * 3) * 5 * 7; //LCM of number 2..10;
    int64_t n; std::cin >> n;
    std::cout << (n / D) << std::endl;

    return 0;
}
// 1537623739917


n=int(input())
import math
x=math.power(5,2)
x=str(x)
print(x[-2:]


#include<bits/stdc++.h>

using namespace std;

int main(){
    cout<<25<<endl;
}


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

key = True
total = m
while key == True:
    for i in range(1, n+1):
        if total <= i:
            break
        total-=i
    if total <= 0:
        key = False

print(total)


n = input().split(' ')
n1 = int(n[0])
m = int(n[1])
while True:
    for i in range(1, n1 + 1):
        if m > i:
            m -= i
        else:
            break
        if i == n1:
            i = 1
    if m < i:
        break
print(m)


n,m = map(int,raw_input().split())
while True:
	for i in range(1,n+1):
		if m < i:
			break
		else:
			m -= i
print m


walruses,chips=map(int,input().split())
while True:
    for i in range (walruses):
        if chips>i+1:
            chips=chips-(i+1)
        else:
            break
print (chips)


r s = map(int, input().split())
print(r, s)


def func(h,n,mark):
	x=2**h
	if(h == 1):
		if(mark == 'L'):
			return 1+(n<=x/2)
		else:
			return 1+(n>x/2)
			# print 'D'
	if(n > x/2):
		return 1+(2**h-1)+func(h-1,n-(2**(h-1)),'R')
	else:
		return 1+func(h-1,n,'L')
h,n=map(int,raw_input().split())
print func(h,n,'R')


h,n = map(int,input().split())
    nn = (2**(h+1))-1
    vis = [False]*(nn+10)
    cn = 1
    cp = False
    nnl = (2**h)-1
    n += nnl
    cnt = 0
    while True:
        if cn > nnl or (vis[cn*2] and vis[cn*2+1]):
            cn //= 2
        elif cp == False:
            if not vis[cn*2]:
                cn *= 2
                cp = True
            else:
                cn = 2*cn + 1
        elif cp == True:
            if not vis[2*cn+1]:
                cn = cn*2+1
                cp = False
            else:
                cn *= 2
        if cn == n:
            break
        if not vis[cn]:
            cnt += 1
            vis[cn] = True
    print(cnt)


#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=a;i<b;i++)
#define mp make_pair
#define pb push_back
#define mod 1000000007

long long h,n,ans;

int main( ){
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin>>h>>n;
    ans=0;
    n-=1;
    bool lef=true;
    while(h>0)
    {
        if((lef&& (n<(1ll<<(h-1))) )||( (!lef)&&n>=(1ll<<(h-1)) ) )
        {
            ans++;
            //if((~lef)&&n>=(1ll<<(h-1))) cout<<"ASDFASDF";
            //cout<<n<<' '<<(1ll<<(h-1))<<' ';
            lef=!lef;
            h--;
            n%=(1ll<<h);
            //cout<<(1ll<<(h-1))<<' ';
        }
        else
        {
            ans+=(1ll<<h);
            h--;
            n%=(1ll<<h);
        }
        //cout<<ans<<' '<<h<<endl;
    }
    cout<<ans;
    return 0;
}


a,b=map(int,input().split())
if(a==b or a=b+1 or a+1==b):
    print('YES')
else:
    print('NO')


a,b = [int(x) for x in input().split()]
if abs(a-b) <= 1:
    print(‘YES’)
else:
    print(‘NO’)


a=int(input())
b=int(input())
c=abs(a-b)
if c==1 || c==0 :
    print("YES")
else :
    print("NO")


import sys
a, b = [int(x) for x in input().split()]
if a=b:
  print("YES")
  sys.exit()
if a>b:
  if (b-a)%2==1:
    print("YES")
  else:
    print("NO")
else:
  if (b-a)%2==1:
    print("YES")
  else:
    print("NO")


import sys
a, b = [int(x) for x in input().split()]
if a=b:
  print("YES")
  sys.exit()
if a>b:
  if a-b==1:
    print("YES")
  else:
    print("NO")
else:
  if b-a==1:
    print("YES")
  else:
    print("NO")


#include <bits/stdc++.h>

using namespace std;
unsigned long long fact(long long n)
{
    if(n==1) return 1;
    else return n*fact(n-1);
}
unsigned long long puissance (long long n,long long p)
{
    unsigned long long i,s=1;
    for(i=0;i<p;i++)
        s=s*n;
    return s;
}

int main()
{

    long long n,x,d;
    cin >>n;
    d=(puissance(10,9)+7);
    x=(puissance(3,3*n)-puissance(7,n))%d;
    cout << x;
    return 0;

}


#define LIN cout << __LINE__ << endl;
#define INF 0x3f3f3f3f
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef unsigned long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll MOD = 1000000007;

ll powmod(ll a, ll b){
  a %= MOD;
  ll res = 1 % MOD;
  while (b){
    if (b&1)
      res = (res * a) % MOD;
    a = a*a % MOD;
    b >>= 1;
  }
  return res % MOD;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);

  ll n;
  cin >> n;

  cout << (powmod(27, n)%MOD - powmod(7, n)%MOD) % MOD << endl;

  return 0;
}


n = int(input()); L = [int(x) for x in input().split()]
p = len([x for i, x in enumerate(L) if x > 0])
m = len([x for i, x in enumerate(L) if x < 0])
if p >= (n+1)//2: print(1)
elif m >= (n+1)//2: print(-1)
else print(0)


n=int(input())
a=list(map(int,input().split()))
n=(n+1)//2
x=0
for i in a:if i>0:x+=1
if x>=n:print(1)
else print(0)


n=int(input())
l=list(map(int,input().split()))
c=0;d=0;e=0
if n==1 and l[0]>0:
	print("2")
	exit()
elif n==1 and l[0]<0:
	print("-2")
	exit()
elif n==1 and l[0]==0:
	print("0")
	exit()
else:
	for i in range(n):
		if l[i]>0:
			c+=1
		elif l[i]<0:
			d+=1
		elif l[i]==0:
			e+=1
if c==d==e and c+e+d=n:
	print("0")
	exit()
elif c>=n//2 and c>=e+d:
	print("2")
elif d>=n//2 and d>=e+c:
	print("-2")
else:
	print("0")


 n = int(input())
a = [int(x) for x in input().split()]
kn = 0
for i in a:
	if i == 0:
		kn += 1
if kn > n // 2:
	print(0)
else:
	ko = 0
	kp = 0
	for i in a:
		if i < 0:
			ko +=1
		else:
			if i != 0:
				kp += 1
	if ko =< n // 2 and kp =< n // 2:
	    print(0)
	    exit()
	if ko == kp:
		print(1)
		exit()
	if ko > kp:
		print(-1)
	else:
		print(1)


line1 = input()
line2 = input()

n = len(line1)

res = 0
ind = 0

while ind < n - 1:
    count = 0
    if line1[ind] == '0':
        count += 1

    if line1[ind+1] == '0':
        count += 1

    if line2[ind] == '0':
        count += 1

    if line2[ind+1] == '0':
        count += 1

    if (count == 3):
        res += 1
        ind += 2
    elif count == 4:
        res += 1
        if ind + 2 <= n - 1:
            if line1[ind + 2] == '0' and line2[ind + 2] == '0':
                res += 1
                ind += 3
        else:
            ind += 2
    else:
        ind += 1

print(res)


list1 = list(input())
list2 = list(input())

i=0
count=0
f1=0
up_u=0
d_u=0
if len(list1)==1:
    print(0)
    exit()
while i<len(list1)-1:
    if list1[i]=='0':

        if list1[i+1] =='0' and i+2<len(list1)-1 and list1[i+2]=='0':
            if list2[i]=='0' and list2[i+1]=='0' and list2[i+2]=='0':
                count+=2
                up_u=i+2
                d_u=i+2
                i+=3

        elif list1[i+1]=='0' and (list2[i+1]=='0' or list2[i]=='0'):
            up_u=i+1
            if list2[i]==0:
                d_u=i
            else:
                d_u=i+1
            count+=1
            i+=2

        elif list2[i]=='0' and list2[i+1]=='0':
            count+=1
            up_u=i
            d_u=i+1

            i+=2
        else:
            i+=1

    elif list2[i]=='0':
        if list2[i+1]=='0' and (list1[i+1]=='0'):
            count+=1
            up_u=i+1
            d_u=i+1
            i+=2
        else:
            i+=1
    else:
        i+=1

if list1[-1]=='0':

    if up_u<len(list1)-1:

        if d_u<len(list2)-2:
            if list2[-1]=='0' and list2[len(list2)-2]=='0':
                count+=1
print(count)


#include<bits/stdc++.h>
#define MOD 1000000007
#define MAX 100003
using namespace std;
using ll = long double;

int main(){
	int t;
	cin>>t;
	while(t--){
		int n ;
		cin>>n;
		ll ar[n];
		for( int i = 0; i<n; i++){
			cin>>ar[i];
		}
		sort(ar, ar+n );
		for(int i = n-1; i>0; i--){
			ar[i-1] = ( ar[i] + ar[i-1])/2.0;
		}
		cout<<ar[0]<<endl;
	}
}


str1 = input()
str2 = input()

l = len(str1)
num = []

for i in range(0, l) :
	num.append(0)
	if str1[i] == '0' : num[i] = num[i] + 1
	if str2[i] == '0' : num[i] = num[i] + 1

now = 0
res = 0
for i in num :
	now = now + i
	if now >= 3 :
		res = res + 1
		now = now - 3
	elif now <= 2 && i != 2 :
		now = i

print(res)


def HOD(a, b):
    if a * b == 0:
        return a + b
    if a > b:
        a, b = b, a
    return HOD(a, b % a)

def main():
    n = int(input())
    a = int(input())
    b = int(input())
    if n % HOD(a, b):
        print('NO')
    else:
        f = 0
        if a < b:
            a, b = b, a
            f = 1
        for i in range(1 + n // a):
            if (n - i * a) % b == 0:
                print('YES')
                if f:
                    print((n - i * a) // b, i)
                else:
                    print(i, (n - i * a) // b)
                return
        print('NO')

main()


def solution (a, b, n):

    # traverse for all possible values
    i = 0
    _atual = i * a
    while _atual <= n:
        _atual = i * a

        # check if it is satisfying
        # the equation
        _res = n - (_atual)
        if _res % b == 0:
            if i < 0 or int(_res/b) < 0:
                print "NO"
                exit()
            print "YES"
            print i, int(_res / b)
            return 0
        i = i + 1
    print "NO"

n = int(raw_input())
a = int(raw_input())
b = int(raw_input())

if a==1 or b==1:
    if a<b:
        print "YES"
        print n, 0
    else:
        print "YES"
        print 0, n
    exit()

solution(a,b,n)


def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
n=int(input());a=int(input());b=int(input())
i=0
if n%(gcd(a,b))!=0:
    print('NO')
else:
    while i*a<=n:
        if (n-(i*a))%b==0:
            print('YES')
            print(i,(n-(i*a))//b)
            exit(0)
        else:i+=1
    print('NO'


from sys import stdin
n = int(stdin.readline())
a = int(stdin.readline())
b = int(stdin.readline()
k = n/a
ans = 'No'
for i in xrange(k+1):
 if (n - i*a)%b==0:
  print 'Yes'
  ans = "%d %d"%(i,(n-a*i)/b)
  break
print ans


    n = int(input())
    a = int(input())
    b = int(input())
    first = n
    if n % a == 0:
        print('YES')
        print(n//a, 0)
    elif n % b == 0:
        print('YES')
        print(0, n // b)
    else:
        while n % a and n > 0:
            n -= b
        if n < 0:
            print('NO')
        else:
            print('YES')
            print(n//a, (first-n) // b)


import sys
import math

def factors(x):
    i = 1
    n = min(x/2, math.sqrt(x))
    while i <= n:
        if x % i == 0:
            yield i
        i = i + 1
    yield x

(n, x) = map(int, sys.stdin.readline().split())

if n*n < x:
    print 0
    exit()

occurrences = [(row, x/row) for row in filter(lambda f: f <= n, factors(x))
                            if  x / row <= n]

print(len(occurrences))


n,k = map(int,input().split())
count=0
for i in range(1,n+1):
    for j in range(1,n+1):

    if j*i==k:
        count+=1
print(count)


#include <stdio.h>

int main() {
    int count = 0;
    int n, find, result;
    int i, j;
    scanf("%d %d", &n, &find);
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            if(i > find || j > find) {
                break;
            }
            result = i*j;
            if(result == find){
                count++;
                break;
            }
            if(result > find){
                break;
            }
        }
    }
    printf("%d\n", count);
}
// 1541254992279


#include <stdio.h>

int main() {
    int count = 0;
    int n, find, result;
    int i, j;
    scanf("%d %d", &n, &find);
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            if(i > find || j > find) {
                break;
            }
            result = i*j;
            if(result == find){
                count++;
                break;
            }
            if(result > find){
                break;
            }
        }
    }
    printf("%d\n", count);
}
/* 1541254918246 */


n, x = [int(i) for i in raw_input().split()]
total = 0
for i in xrange(1, int(x**.5)+1):
    f = x%i
    if x%i == 0 and i <=n and x/i <= n:
        total += 1
    if x/float(i) == i:
        total -= .5
return int(2*total)


#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);

    int n, m, k;
    cin >> n >> m >> k;

    vector<pii> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a.begin(), a.end(), greater<pii>());

    vector<int> ind(m*k);
    ll sumBeauty = 0;
    for(int i = 0; i < m*k; ++i) {
        sumBeauty += a[i].first;
        ind[i] = a[i].second;
    }

    sort(ind.begin(), ind.end());

    vector<int> division(k-1);
    for(int i = 0; i < k-1; ++i)
        division[i] = ind[(i+1)*m - 1];

    cout << sumBeauty << endl;
    for(int p: division)
        cout << p + 1 << " ";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n, b;
ll ans=0;
int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n>>b;
    for (ll i=b; i<=n; i*=b)
    {
        ans+=n/i;
    }
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
typedef pair<pair<LL,int>,pair<int,int>> PP;
#define _x first
#define _y second

LL quick_pow(LL x,LL n,LL m){
	LL res = 1;
	while(n > 0){
		if(n & 1)	res = res * x % m;
		x = x * x % m;
		n >>= 1;//相当于n=n/2.详情请参考位移运算符。
	}
	return res;
}

bool Less(const PP& s1, const PP& s2)
{
    if(s1.first.first==s2.first.first)  return s1.first.second > s2.first.second;
    return s1.first.first < s2.first.first; //从小到大排序
}

struct hashfunc {
	template<typename T, typename U>
	size_t operator()(const pair<T, U> &i) const {
		return hash<T>()(i.first) ^ hash<U>()(i.second);
	}
};

unordered_map<pair<LL, LL>, LL, hashfunc> umii;

int main()
{
    freopen("input", "r", stdin);
    // freopen("output", "w", stdout);
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    LL n,m,k;
    cin>>n>>m>>k;
    vector<LL> vi,temp;
    for(LL i=0;i<n;i++){
      LL t;cin>>t;
      vi.push_back(t);
    }
    temp = vi;
    LL ans=0;
    sort(temp.begin(),temp.end());
    reverse(temp.begin(),temp.end());
    unordered_map<int,int> umii;
    for(LL i=0;i<k*m;i++){
      umii[temp[i]]++;
      ans+=temp[i];
    }
    cout<<ans<<endl;
    int tt = 0;
    int num = k;
    for(int i=0;i<n;i++){
      if(umii[vi[i]]!=0){
        umii[vi[i]]--;
        tt++;
        // cout<<vi[i]<<endl;
        if(tt==m){
          num--;
          // cout<<"jj"<<num<<endl;
          if(num!=0)
            cout<<i+1<<" ";
          tt=0;
        }
      }
    }
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
    int n, b, ans;
    cin >> n >> b;
    vector<int> div;
    vector<int> cnt;
    int b1 = b;
    for (int i = 2; i * i <= b; i++) {
        if (b1 % i == 0) {
            div.push_back(i);
            cnt.push_back(0);
            while (b1 % i == 0) {
                cnt[div.size() - 1]++;
                b1 /= i;
            }
        }
    }
    if (b1 != 1) {
        div.push_back(b1);
        cnt.push_back(1);
    }
    for (int i = 0; i < div.size(); i++) {
    int curr = div[i];
    int cnt1 = cnt[i];
    int ans1 = 0;
    for (int k = 1; curr <= n; k++) {
        ans1 += n / curr;
        if (curr <= (n + div[i] - 1) / div[i]) break;
        curr *= div[i];
    }
    if (i == 0) ans = ans1 / cnt1;
    else ans = min(ans, ans1 / cnt1);
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

#define ll unsigned long long int

#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define all(x) (x).begin(), (x).end()

#define INF 2147483647
#define MAXN 200004
#define endl "\n"

ll mod = 1000000007;

vector<pll> v;

void factorize(ll n)
{
    int count = 0;
    while (!(n % 2)) {
        n >>= 1;
        count++;
    }
	if(count > 0){
		v.pb(mp(2, count));
	}

    for (ll i = 3; i <= sqrt(n); i += 2) {
        count = 0;
        while (n % i == 0) {
            count++;
            n = n / i;
        }
		if(count > 0){
			v.pb(mp(i, count));
		}
    }
    if (n > 2){
		v.pb(mp(n,1));
	}
}

int main()
{
	_cin;
	ll n, b, m;
	cin >> n >> b;
	factorize(b);
	ll sz = v.size(), denum, tmp, num, ans = 0, ct;
	for(int i=0; i<sz; i++){
		m = v[i].fi;
		// cout << m << " " << v[i].se << endl;
		ct = 0;
		num = n;
		denum = m;
		while(1){
			tmp = num / denum;
			ct += tmp;
			denum = denum * m;
			if(tmp == 0) break;
		}
		ct = ct / v[i].se;
		if(ans == 0) ans = ct;
		else ans = min(ans, ct);
	}
	cout << ans << endl;
	return 0;
}