[Image] 

It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the information can cause discord in the kingdom of Sweetland in case it turns out to reach the wrong hands. So it's a necessity to not let any uninvited guests in.

There are 26 entrances in Jelly Castle, enumerated with uppercase English letters from A to Z. Because of security measures, each guest is known to be assigned an entrance he should enter the castle through. The door of each entrance is opened right before the first guest's arrival and closed right after the arrival of the last guest that should enter the castle through this entrance. No two guests can enter the castle simultaneously.

For an entrance to be protected from possible intrusion, a candy guard should be assigned to it. There are k such guards in the castle, so if there are more than k opened doors, one of them is going to be left unguarded! Notice that a guard can't leave his post until the door he is assigned to is closed.

Slastyona had a suspicion that there could be uninvited guests at the evening. She knows the order in which the invited guests entered the castle, and wants you to help her check whether there was a moment when more than k doors were opened.


-----Input-----

Two integers are given in the first string: the number of guests n and the number of guards k (1 ≤ n ≤ 10^6, 1 ≤ k ≤ 26).

In the second string, n uppercase English letters s_1s_2... s_{n} are given, where s_{i} is the entrance used by the i-th guest.


-----Output-----

Output «YES» if at least one door was unguarded during some time, and «NO» otherwise.

You can output each letter in arbitrary case (upper or lower).


-----Examples-----
Input
5 1
AABBB

Output
NO

Input
5 1
ABABB

Output
YES



-----Note-----

In the first sample case, the door A is opened right before the first guest's arrival and closed when the second guest enters the castle. The door B is opened right before the arrival of the third guest, and closed after the fifth one arrives. One guard can handle both doors, as the first one is closed before the second one is opened.

In the second sample case, the door B is opened before the second guest's arrival, but the only guard can't leave the door A unattended, as there is still one more guest that should enter the castle through this door.

Difficulty: EASY
Tags: Data structures

Implementation
Skill types: Data structures

Starter code:

Solutions:
import os
from io import BytesIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, k) = map(int, input().split())
g = [x - 65 for x in input()]
e = [-1] * 26
for i in range(n):
	e[g[i]] = i
curS = 0
met = [0] * 26
for i in range(n):
	if not met[g[i]]:
		curS += 1
		met[g[i]] = 1
	if curS > k:
		print('YES')
		exit()
	if i == e[g[i]]:
		curS -= 1
print('NO')


(guests, guards) = map(int, input().split())
arrival = input()
inactive = [0] * 26
active = [0] * 26
flag = 0
for i in range(guests):
	each = arrival[i]
	inactive[ord(each) - 65] = i
for i in range(guests):
	each = arrival[i]
	active[ord(each) - 65] = 1
	if sum(active) > guards:
		flag = 1
		break
	if inactive[ord(each) - 65] == i:
		active[ord(each) - 65] = 0
if flag == 1:
	print('YES')
else:
	print('NO')


fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from re import *
from sys import *
from math import *
from heapq import *
from queue import *
from bisect import *
from string import *
from itertools import *
from collections import *
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from collections import Counter as cc
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = 1
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)

def output(answer):
	stdout.write(str(answer))
(n, k) = zz()
arr = fast()
stack = set()
lst = [0] * 26
for i in arr:
	x = ord(i) - 65
	lst[x] += 1
for i in arr:
	stack.add(i)
	x = ord(i) - 65
	lst[x] -= 1
	t = 0
	if lst[x] == 0:
		stack.remove(i)
		t = 1
	if len(stack) + t > k:
		print('YES')
		exit()
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
l = [0] * 26
f = 0
for i in range(n):
	a = s[i]
	l[ord(a) - 65] = i
out = []
for i in range(n):
	if s[i] not in out:
		out.append(s[i])
	if len(out) > k:
		print('YES')
		f = 1
		break
	if i == l[ord(s[i]) - 65]:
		out.remove(s[i])
if f == 0:
	print('NO')


(n, k) = input().strip().split()
n = int(n)
k = int(k)
s = input()
m = []
a = []
if k > n or k == 26:
	print('NO')
else:
	b = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
	i = 0
	while i < n:
		while s[i] in b:
			l = s.find(s[i])
			p = s.rfind(s[i])
			b.remove(s[i])
			if p not in m:
				m.append(p)
			if l not in a:
				a.append(l)
			if len(b) == 0:
				break
			i += 1
		i += 1
	q = len(m)
	w = len(a)
	f = 1
	for i in range(q - 1):
		if m[i] != a[i]:
			for j in range(i + 1, w):
				if m[i] > a[j]:
					k -= 1
					break
			for j in range(i + 1, w):
				if m[i] < a[j]:
					k += 1
					break
			if k == 0:
				break
	if k > 0:
		print('NO')
	else:
		print('YES')


from collections import Counter
(n, k) = list(map(int, input().split()))
q = input()
(last_index, first_index) = ({}, {})
for (i, s) in enumerate(q):
	last_index[s] = i
	first_index[s] = min(first_index.get(s, 10 ** 6 + 5), i)
opened_count = 0
for (i, d) in enumerate(q):
	if i == first_index[d]:
		opened_count += 1
	if opened_count > k:
		print('YES')
		exit(0)
	if i == last_index[d]:
		opened_count -= 1
print('NO')


def main():
	(n, g) = [int(x) for x in input().split()]
	data = input()
	dats = set(data)
	if len(dats) <= g:
		return 'NO'
	inicio = []
	final = []
	for val in dats:
		inicio.append(data.index(val))
	dfls = list(dats)
	for end in range(n - 1, -1, -1):
		if data[end] in dfls:
			final.append(end)
			dfls.remove(data[end])
		if not len(dfls):
			break
	inicio.sort()
	final.sort()
	total = 0
	(i, f) = (0, 0)
	while i < len(inicio):
		if inicio[i] <= final[f]:
			total += 1
			i += 1
		else:
			total -= 1
			f += 1
		if total > g:
			return 'YES'
	return 'NO'
print(main())


import os

def main():
	(_n, _k, _g) = os.read(0, os.fstat(0).st_size).split()
	(n, k) = (int(_n), int(_k))
	g = [x - 65 for x in _g]
	e = [-1] * 26
	for i in range(n):
		e[g[i]] = i
	curS = 0
	f = 1
	met = [0] * 26
	for i in range(n):
		if not met[g[i]]:
			curS += 1
			met[g[i]] = 1
		if curS > k:
			f = 0
			break
		if i == e[g[i]]:
			curS -= 1
	print('NO' if f else 'YES')
main()


def main():
	opened = {}
	closed = {}
	(n, k) = map(int, input().split())
	seq = input()
	for (i, way) in enumerate(seq):
		if way not in opened:
			opened[way] = i
		closed[way] = i
	for (i, way) in enumerate(seq):
		open_ith_door = opened[way] == i
		if open_ith_door:
			k -= 1
			no_guardians = k < 0
			if no_guardians:
				print('YES')
				return
		close_ith_door = closed[way] == i
		if close_ith_door:
			k += 1
		else:
			continue
	print('NO')
	return
main()


(n, k) = map(int, input().split())
s = input()
d = {}
for i in range(n):
	d[s[i]] = i
st = set()
f = False
for i in range(n):
	st.add(s[i])
	if len(st) > k:
		f = True
		break
	if d[s[i]] == i:
		st.remove(s[i])
if f:
	print('YES')
else:
	print('NO')


(n, k) = [int(i) for i in input().split(' ')]
guests = input()
flag = 'NO'
guards = [' '] * k
for i in range(0, n):
	if guests[i] in guards:
		continue
	if ' ' in guards:
		guards[guards.index(' ')] = guests[i]
		continue
	rest_guests = guests[i:]
	flag = 'YES'
	for g in guards:
		if g in rest_guests:
			continue
		else:
			guards[guards.index(g)] = guests[i]
			flag = 'NO'
	if flag == 'YES':
		break
print(flag)


import math as mt
import sys, string
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, k) = M()
s = input().strip()
l = [0] * 26
v = [0] * 26
g = 0
for i in s:
	l[ord(i) - 65] += 1
for i in s:
	if v[ord(i) - 65] == 0:
		v[ord(i) - 65] = 1
		if g < k:
			g += 1
			l[ord(i) - 65] -= 1
			if l[ord(i) - 65] == 0:
				g -= 1
		else:
			print('YES')
			exit()
	else:
		l[ord(i) - 65] -= 1
		if l[ord(i) - 65] == 0:
			g -= 1
print('NO')


(n, k) = map(int, input().split())
s = input()
C = [0] * (n + 1)
for ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
	if ch in s:
		C[s.find(ch)] += 1
		C[s.rfind(ch) + 1] -= 1
x = 0
for c in C:
	x += c
	if x > k:
		print('YES')
		break
else:
	print('NO')


from string import ascii_uppercase as let
import sys

def main():
	(n, k) = map(int, input().split())
	l = input()
	a = [0 for i in range(26)]
	for i in l:
		a[let.index(i)] += 1
	fk = k
	od = set()
	for i in l:
		if i not in od:
			fk -= 1
			if fk < 0:
				print('YES')
				return
			od.add(i)
		a[let.index(i)] -= 1
		if a[let.index(i)] == 0:
			od.remove(i)
			fk += 1
	print('NO')
main()


(n, k) = list(map(int, input().split()))
s = input()
start = [-1] * 26
end = [-1] * 26
for i in range(n):
	door = ord(s[i]) - ord('A')
	end[door] = i
	if start[door] == -1:
		start[door] = i
l = []
for i in range(26):
	l.append([i, 1, start[i]])
	l.append([i, -1, end[i]])
l = sorted(l, key=lambda x: x[2])
num = 0
m = 0
for i in l:
	num += i[1]
	m = max(m, num)
if m > k:
	print('YES')
else:
	print('NO')


def add_up_array(arr, k, n):
	for i in range(1, n):
		arr[i] = arr[i] + arr[i - 1]
		if arr[i] > k:
			return 'YES'
	return 'NO'
(n, k) = map(int, input().split())
entrances = input()
added = set()
last_index = {}
doors_opened = [0] * (len(entrances) + 1)
for i in range(len(entrances)):
	last_index[entrances[i]] = i
for (i, c) in enumerate(entrances):
	if c not in added:
		doors_opened[i] += 1
		added.add(c)
	if i == last_index[c]:
		doors_opened[i + 1] -= 1
print(add_up_array(doors_opened, k, n))


import string
(n, k) = map(int, input().split())
(s, d, v) = (input(), [0] * (n + 1), 0)
for ch in string.ascii_uppercase:
	if ch in s:
		d[s.find(ch)] += 1
		d[s.rfind(ch) + 1] -= 1
for x in d:
	v += x
	if v > k:
		print('YES')
		exit()
print('NO')


(n, k) = input().split()
n = int(n)
k = int(k)
inp = input()
s = []
e = []
seen = set()
for c in inp:
	if c not in seen:
		s.append('s')
		seen.add(c)
	else:
		s.append('.')
seen = set()
for i in range(len(inp) - 1, -1, -1):
	if inp[i] not in seen:
		e.append('e')
		seen.add(inp[i])
	else:
		e.append('.')
e = e[::-1]
cnt = 0
maxcnt = 0
for i in range(len(inp)):
	if s[i] == 's':
		cnt += 1
	maxcnt = max(cnt, maxcnt)
	if e[i] == 'e':
		cnt -= 1
if maxcnt > k:
	print('YES')
else:
	print('NO')


(n, k) = input().split()
n = int(n)
k = int(k)
l = input()
d = {}
for val in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
	d[val] = 0
for val in l:
	d[val] += 1
opened = {}
flag = 0
for val in l:
	if val not in opened:
		opened[val] = 1
	d[val] -= 1
	if len(opened) > k:
		flag = 1
		break
	if d[val] == 0:
		del opened[val]
if flag == 0:
	print('NO')
else:
	print('YES')


(n, k) = list(map(int, input().split()))
s = list(str(input()))
m = set(s)
t = [[s.index(i), n - s[::-1].index(i) - 1] for i in m]
possible = False
for i in range(len(m)):
	g = 0
	for j in range(len(m)):
		if t[j][0] <= t[i][0] <= t[j][1]:
			g += 1
		if g > k:
			possible = True
print('YES' if possible else 'NO')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
t = 1
for _ in range(1):
	(n, k) = inp()
	s = input()
	freq = Counter(s)
	dic = defaultdict(bool)
	flag = True
	for i in s:
		freq[i] -= 1
		if not dic[i]:
			if k == 0:
				flag = False
				break
			k -= 1
			dic[i] = True
		if freq[i] == 0:
			k += 1
	if flag:
		print('NO')
	else:
		print('YES')


from collections import defaultdict as dd
(a, k) = [int(i) for i in input().split()]
b = input()
al = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
come = [0] * 26
out = [0] * 26
for i in range(a):
	if come[al.index(b[i])] == 0:
		come[al.index(b[i])] = i + 1
		out[al.index(b[i])] = i + 1
	else:
		out[al.index(b[i])] = i + 1
cm = []
for i in range(26):
	if come[i] != 0 and out[i] != 0:
		cm.append((come[i], 1))
		cm.append((out[i], 2))
cm.sort()
ma = 0
ans = 0
for i in cm:
	if i[1] == 1:
		ma += 1
	else:
		ma -= 1
	ans = max(ma, ans)
if k >= ans:
	print('NO')
else:
	print('YES')


(n, k) = map(int, input().split())
s = input()
fix = {}
a = {}
for i in range(n):
	if s[i] in fix:
		fix[s[i]] += 1
	else:
		fix[s[i]] = 1
for i in range(n):
	fix[s[i]] -= 1
	if not s[i] in a:
		k -= 1
		a[s[i]] = 1
	if k == -1:
		print('YES')
		exit()
	if fix[s[i]] == 0:
		k += 1
print('NO')


(n, k) = map(int, input().split())
s = list(input())
op = [n for _ in range(26)]
cl = [-1 for _ in range(26)]
for i in range(n):
	j = ord(s[i]) - ord('A')
	op[j] = min(op[j], i)
	cl[j] = max(cl[j], i)
cnt = [0 for _ in range(2 * n + 1)]
for i in range(26):
	if op[i] < n:
		cnt[op[i] * 2 + 1] += 1
	if -1 < cl[i]:
		cnt[cl[i] * 2 + 2] -= 1
for i in range(1, 2 * n + 1):
	cnt[i] += cnt[i - 1]
if k < max(cnt):
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
if k >= len(set(s)):
	print('NO')
	quit()
l = {}
for e in set(s):
	l[e] = len(s) - 1 - s[::-1].index(e)
g = set()
for x in range(n):
	if s[x] in g:
		if x >= l[s[x]]:
			k += 1
			g.discard(s[x])
	elif x >= l[s[x]]:
		if k > 0:
			continue
		else:
			print('YES')
			quit()
	else:
		g.add(s[x])
		k -= 1
		if k < 0:
			print('YES')
			quit()
print('YES' if k < 0 else 'NO')


from sys import stdin, stdout
import string
(n, k) = map(int, stdin.readline().rstrip().split())
s = list(stdin.readline().rstrip())
doorOpen = {}
doorClosed = {}
for i in range(n):
	if s[i] not in doorOpen.keys():
		doorOpen[s[i]] = i
for i in range(n - 1, -1, -1):
	if s[i] not in doorClosed.keys():
		doorClosed[s[i]] = i
events = [(x, 'o') for x in doorOpen.values()] + [(x, 'x') for x in doorClosed.values()]
events.sort(key=lambda x: x[1])
events.sort(key=lambda x: x[0])
opened = 0
unguarded = False
for i in range(len(events)):
	if events[i][1] == 'o':
		opened += 1
	else:
		opened -= 1
	if opened > k:
		unguarded = True
		break
if unguarded:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
mx = dict()
for x in range(n):
	mx[s[x]] = x
cur = 0
ans = 0
c = {x.upper(): 0 for x in 'qwertyuiopasdfghjklzxcvbnm'}
for x in range(n):
	if c[s[x]] == 0:
		cur += 1
		c[s[x]] = 1
	if cur > k:
		ans = 1
	if mx[s[x]] == x:
		cur -= 1
		c[s[x]] = 0
print('NO' if not ans else 'YES')


(n, k) = map(int, input().split())
g = tuple(map(ord, input()))
e = [-1] * 91
for i in range(n):
	e[g[i]] = i
curS = 0
f = 1
met = [0] * 91
for i in range(n):
	if met[g[i]]:
		if i == e[g[i]]:
			curS -= 1
		continue
	curS += 1
	met[g[i]] = 1
	if curS > k:
		f = 0
		break
	if i == e[g[i]]:
		curS -= 1
if f:
	print('NO')
else:
	print('YES')


l = input().split()
n = int(l[0])
k = int(l[1])
s = input()
lens = len(s)
first = []
fn = []
last = []
ln = []
for i in range(lens):
	if s[i] not in first:
		first.append(s[i])
		fn.append(i)
	if s[lens - i - 1] not in last:
		last.append(s[lens - i - 1])
		ln.append(lens - i - 1)
ln.sort()
more = False
d = 0
ad = None
rm = None
while not more:
	if ad == None:
		if len(fn) == 0:
			break
		ad = fn.pop(0)
	if rm == None:
		rm = ln.pop(0)
	if ad < rm:
		d += 1
		ad = None
	elif ad > rm:
		d -= 1
		rm = None
	else:
		ad = None
		rm = None
		if d + 1 > k:
			more = True
	if d > k:
		more = True
if more:
	print('YES')
else:
	print('NO')


import sys

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def nninp():
	return map(int, sys.stdin.readline().strip().split())

def llinp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
(n, k) = nninp()
s = stl(ssinp())
s.reverse()
arr = [-1] * 26
for i in range(n):
	if arr[ord(s[i]) - 65] == -1:
		arr[ord(s[i]) - 65] = n - i - 1
s.reverse()
guard = [0] * 26
f = 0
for i in range(n):
	if guard[ord(s[i]) - 65] == 0:
		guard[ord(s[i]) - 65] = 1
		if sum(guard) > k:
			print('YES')
			f = 1
			break
	if arr[ord(s[i]) - 65] == i:
		guard[ord(s[i]) - 65] = 0
if f == 0:
	print('NO')


(n, k) = map(int, input().split())
if n > k:
	s = input()
	counts = [0] * 26
	offset = ord('A')
	for i in s:
		counts[ord(i) - offset] += 1
	is_closed = [None] * 26
	count = 26 - counts.count(None)
	if k < count:
		for i in s:
			pos = ord(i) - offset
			if is_closed[pos] == None:
				if k > 0:
					k -= 1
					is_closed[pos] = False
				elif k == 0:
					print('YES')
					break
			elif is_closed[pos]:
				print('YES')
				break
			counts[pos] -= 1
			if counts[pos] == 0:
				is_closed[pos] = True
				k += 1
		else:
			print('NO')
	else:
		print('NO')
else:
	print('NO')


import os
from io import BytesIO

def main():
	input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
	(n, k) = map(int, input().split())
	g = [x - 65 for x in input()]
	e = [-1] * 26
	for i in range(n):
		e[g[i]] = i
	curS = 0
	f = 1
	met = [0] * 26
	for i in range(n):
		if not met[g[i]]:
			curS += 1
			met[g[i]] = 1
		if curS > k:
			f = 0
			break
		if i == e[g[i]]:
			curS -= 1
	print('NO' if f else 'YES')
main()


from collections import *
(n, k) = map(int, input().split())
s = input()
a = Counter(s)
(x, c) = (0, 0)
cnt = {}
for i in s:
	if i in cnt:
		cnt[i] += 1
	else:
		cnt[i] = 1
		c += 1
	x = max(x, c)
	if cnt[i] == a[i]:
		c -= 1
print('YES' if x > k else 'NO')


(n, k) = map(int, input().split())
st = input()
s = set(st)
ans = 0
d = [0] * n
for i in s:
	for j in range(st.find(i), st.rfind(i) + 1):
		d[j] += 1
if max(d) > k:
	print('YES')
else:
	print('NO')


import sys

def func(dic1, dic2, s, alot):
	for i in s:
		if dic2[i] == 0:
			alot += 1
			dic2[i] += 1
		else:
			dic2[i] += 1
		if alot > guards:
			return False
		if dic2[i] == dic1[i]:
			alot -= 1
	return True
dic1 = {}
dic2 = {}
(guests, guards) = [int(x) for x in sys.stdin.readline().split()]
s = sys.stdin.readline().strip()
for i in s:
	if i not in dic1:
		dic1[i] = 1
		dic2[i] = 0
	else:
		dic1[i] += 1
alot = 0
if func(dic1, dic2, s, alot):
	sys.stdout.write('NO')
else:
	sys.stdout.write('YES')


(n, k) = list(map(int, input().split()))
s = input()
cq = [0] * 26
do = [0] * 26
a = ord('A')
for i in s:
	cq[ord(i) - a] += 1
cntr = 0
for i in s:
	ind = ord(i) - a
	if do[ind] == 0:
		cntr += 1
	do[ind] += 1
	if cntr > k:
		print('YES')
		return
	if do[ind] == cq[ind]:
		cntr -= 1
print('NO')


(n, k) = input().split()
(n, k) = (int(n), int(k))
s = input()
d = {}
f = {}
for i in range(65, 65 + 26):
	d[chr(i)] = 0
	f[chr(i)] = 0
for i in s:
	d[i] += 1
num = 0
for i in s:
	if f[i] == 0:
		num += 1
		if num > k:
			print('YES')
			exit()
	f[i] += 1
	if f[i] == d[i]:
		num -= 1
print('NO')


import sys
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')
(n, k) = map(int, input().split())
s = input()
end = {}
start = {}
for i in range(len(s)):
	if s[i] not in start:
		start[s[i]] = i
	end[s[i]] = i
st = list(start.values())
en = list(end.values())
st = set(st)
en = set(en)
c = 0
f = True
for i in range(n):
	if i in st:
		c += 1
	if c > k:
		f = False
		break
	if i in en:
		c -= 1
if f:
	print('NO')
else:
	print('YES')


(n, k) = map(int, input().split())
s = input()
close = dict()
for i in range(n - 1, -1, -1):
	if close.get(s[i], -1) == -1:
		close[s[i]] = i
Open = 0
door = dict()
for i in range(n):
	if door.get(s[i], -1) == -1:
		Open += 1
		door[s[i]] = 1
	if Open > k:
		print('YES')
		exit()
	if i == close[s[i]]:
		Open -= 1
print('NO')


(n, k) = map(int, input().split())
s = list(input())
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
quards = {letters[i]: 0 for i in range(26)}
for i in range(n):
	quards[s[i]] += 1
d = []
for (key, value) in quards.items():
	if not value:
		d.append(key)
for key in d:
	del quards[key]
ready = k
now = []
flag = True
for man in s:
	if man not in now:
		if ready:
			ready -= 1
			now.append(man)
		else:
			print('YES')
			flag = False
			break
	quards[man] -= 1
	if not quards[man]:
		ready += 1
		now.remove(man)
if flag:
	print('NO')


(numberofguests, numberofgaurds) = map(int, input().split())
entrance_doors = input().strip()
dic = {}
entrance_doors_set = set()
for i in range(numberofguests):
	dic[entrance_doors[i]] = i
for i in range(numberofguests):
	entrance_doors_set.add(entrance_doors[i])
	if len(entrance_doors_set) > numberofgaurds:
		print('YES')
		break
	if i == dic[entrance_doors[i]]:
		entrance_doors_set.remove(entrance_doors[i])
if len(entrance_doors_set) <= numberofgaurds:
	print('NO')


(n, k) = map(int, input().split())
s = list(map(lambda x: ord(x) - ord('A'), input()))
c = [0] * 26
o = [0] * 26
for i in range(n):
	c[s[i]] += 1
for i in range(n):
	x = s[i]
	if o[x] == 0:
		if k == 0:
			print('YES')
			exit()
		k -= 1
		o[x] = 1
	c[x] -= 1
	if c[x] == 0:
		o[x] = 0
		k += 1
print('NO')


(n, k) = map(int, input().split())
doors = input()
lo = [-1] * 26
for i in range(len(doors)):
	cc = ord(doors[i]) - ord('A')
	lo[cc] = i
opened = set()
exceeded = False
for i in range(len(doors)):
	cc = ord(doors[i]) - ord('A')
	opened.add(cc)
	if len(opened) > k:
		exceeded = True
		break
	if i == lo[cc]:
		opened.remove(cc)
print('YES' if exceeded else 'NO')


(N, K) = list(map(int, input().split()))
s = input()
llist = [[-1, -1] for i in range(26)]
dic = {}
for i in range(len(s)):
	if s[i] not in dic:
		dic[s[i]] = [i]
	else:
		dic[s[i]].append(i)
for i in dic.keys():
	llist[ord(i) - ord('A')][0] = dic[i][0]
	llist[ord(i) - ord('A')][1] = dic[i][-1]
count = 0
temp = 0
for i in range(N):
	count = 0
	for j in range(26):
		if i >= llist[j][0] and i <= llist[j][1]:
			count += 1
	if count > K:
		temp = 1
		break
if temp == 1:
	print('YES')
else:
	print('NO')


(string_len, condition_value) = (int(x) for x in input().split())
idx___letter = list(input())
letter___start__finish = {}
for (idx, letter) in enumerate(idx___letter):
	if letter not in letter___start__finish:
		letter___start__finish[letter] = [idx, idx]
	if letter___start__finish[letter][1] < idx:
		letter___start__finish[letter][1] = idx
max_events_open = 0
curr_events_open = 0
for (idx, letter) in enumerate(idx___letter):
	(start, close) = letter___start__finish[letter]
	if idx == start:
		curr_events_open += 1
		max_events_open = max(max_events_open, curr_events_open)
	if idx == close:
		curr_events_open -= 1
if max_events_open > condition_value:
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
S = input()
A = {}
B = {}
for i in range(n):
	if S[i] in B:
		B[S[i]] = i
	else:
		A[S[i]] = i
		B[S[i]] = i
F = 'NO'
P = {}
for i in range(n):
	P[S[i]] = 1
	if len(P) > k:
		F = 'YES'
		break
	if i == B[S[i]]:
		P.pop(S[i])
print(F)


(n, k) = map(int, input().split())
s = input()
d1 = {}
d2 = {}
for (i, v) in enumerate(s):
	if v not in d1:
		d1[v] = i
	d2[v] = i
order = []
for v in d1:
	order.append((d1[v], -1))
	order.append((d2[v], 1))
order.sort()
cur = k
for (_, v) in order:
	cur += v
	if cur < 0:
		print('YES')
		break
else:
	print('NO')


(n, k) = [int(x) for x in input().split()]
a = [ord(x) for x in list(input())]
b = [0] * 32
for i in a:
	b[i - 65] += 1
c = [0] * 32
i = 0
f = 0
for i in a:
	c[i - 65] += 1
	if c[i - 65] == 1:
		k -= 1
		if k < 0:
			f = 1
			break
	if c[i - 65] == b[i - 65]:
		k += 1
if f == 1:
	print('YES')
else:
	print('NO')


(number, guard) = map(int, input().split())
line = input()
record = [[-1, -1] for i in range(0, 26)]
for i in range(0, len(line)):
	if record[ord(line[i]) - ord('A')][0] == -1:
		record[ord(line[i]) - ord('A')][0] = i
	if i > record[ord(line[i]) - ord('A')][1]:
		record[ord(line[i]) - ord('A')][1] = i
F = True
for i in range(0, len(line)):
	if i == record[ord(line[i]) - ord('A')][0]:
		guard -= 1
		if guard < 0:
			F = False
	if i == record[ord(line[i]) - ord('A')][1]:
		guard += 1
if F:
	print('NO')
else:
	print('YES')


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

class FastI(BytesIO):
	newlines = 0

	def __init__(self, fd=0, bufsize=8192):
		self.fd = fd
		self.bufsize = bufsize
		self.read = lambda : super(FastI, self).read() if self.newlines else os.read(self.fd, os.fstat(self.fd).st_size)

	def readline(self):
		while self.newlines == 0:
			(b, ptr) = (os.read(self.fd, max(os.fstat(self.fd).st_size, self.bufsize)), self.tell())
			(self.seek(0, 2), self.write(b), self.seek(ptr))
			self.newlines += b.count(b'\n') + (not b)
		self.newlines -= 1
		return super(FastI, self).readline()

class FastO(IOBase):

	def __init__(self, fd=1):
		stream = BytesIO()
		self.flush = lambda : os.write(fd, stream.getvalue()) and (not stream.truncate(0)) and stream.seek(0)
		self.write = stream.write if sys.version_info[0] < 3 else lambda b: stream.write(b.encode())

class ostream:

	def __lshift__(self, a):
		if a == endl:
			sys.stdout.write('\n')
			sys.stdout.flush()
		else:
			sys.stdout.write(str(a))
		return self
(sys.stdin, sys.stdout) = (FastI(), FastO())
(cout, endl) = (ostream(), object())
input = sys.stdin.readline

def main():
	(n, k) = map(int, input().split())
	s = input().rstrip(b'\r\n')
	(o, c) = ([-1] * 26, [-1] * 26)
	for i in range(n):
		if o[s[i] - 65] == -1:
			o[s[i] - 65] = i
		c[s[i] - 65] = i
	j = 0
	for i in range(n):
		if o[s[i] - 65] == i:
			j += 1
		if j > k:
			print('YES')
			return
		if c[s[i] - 65] == i:
			j -= 1
	print('NO')
main()


(n, r) = map(int, input().split())
s = input()
x = {}
y = set()
for j in range(n):
	x[s[j]] = j
for j in range(n):
	y.add(s[j])
	if len(y) > r:
		print('YES')
		break
	if j == x[s[j]]:
		y.remove(s[j])
if len(y) <= r:
	print('NO')


def if_unguarded(n, k, guest):
	last_guest = dict()
	open_gate = set()
	for i in range(n):
		last_guest[guest[i]] = i
	for i in range(n):
		open_gate.add(guest[i])
		if len(open_gate) > k:
			return 'YES'
		if i == last_guest[guest[i]]:
			open_gate.remove(guest[i])
	if len(open_gate) <= k:
		return 'NO'
(n, k) = list(map(int, input().split()))
guest = input()
print(if_unguarded(n, k, guest))


(n, k) = map(int, input().split())
entrances = input()
di = {}
s = set()
for i in range(n):
	di[entrances[i]] = i
for i in range(n):
	s.add(entrances[i])
	if len(s) > k:
		print('YES')
		break
	if di[entrances[i]] == i:
		s.remove(entrances[i])
else:
	print('NO')


(n, k) = list(map(int, input().split()))
p = input()
(ls, nlaps) = ([], 0)
for i in range(65, 91):
	if chr(i) in p:
		start = p.index(chr(i))
		end = p.rfind(chr(i))
		ls.append((start, 'start'))
		ls.append((end, 'end'))
ls = list(sorted(ls, key=lambda x: x[0]))
maxl = 0
for (i, x) in enumerate(ls):
	if x[1] == 'start':
		nlaps += 1
	else:
		nlaps -= 1
	maxl = max(maxl, nlaps)
if k >= maxl:
	print('NO')
else:
	print('YES')


from sys import stdin
(n, k) = list(map(int, stdin.readline().rstrip().split()))
data = stdin.readline().rstrip()
doors = {}
for c in data:
	if c in doors:
		doors[c] += 1
	else:
		doors[c] = 1
opening_doors_count = 0
opened_doors = {}
for c in data:
	if c not in opened_doors:
		opened_doors[c] = True
		opening_doors_count += 1
	if opening_doors_count > k:
		print('YES')
		return
	doors[c] -= 1
	if doors[c] == 0:
		opening_doors_count -= 1
		opened_doors[c] = False
print('NO')


(n, k) = map(int, input().split())
s = input()
s = list(s)
m = 0
a = [0] * 26
b = [0] * 26
for i in s:
	q = ord(i) - 65
	a[q] += 1
for i in s:
	q = ord(i) - 65
	if a[q] > 0:
		if b[q] == 0:
			if k == 0:
				m = 1
				break
			b[q] = 1
			k -= 1
		a[q] -= 1
		if a[q] == 0:
			k += 1
			b[q] = 1
if m == 0:
	print('NO')
else:
	print('YES')


(n, k) = map(int, input().split())
list1 = input()
s = set([])
f = 0
for i in range(n):
	ff = 0
	if list1[i] in s:
		if list1.find(list1[i], i + 1) == -1:
			s.remove(list1[i])
	else:
		ff = 1
		s.add(list1[i])
	if len(s) > k:
		f = 1
		break
	if ff == 1:
		if list1.find(list1[i], i + 1) == -1:
			s.remove(list1[i])
if f == 1:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
A = input()
D = dict()
B = [0] * len(A)
for i in range(len(A)):
	if A[i] not in D:
		D[A[i]] = [i, i]
	else:
		D[A[i]][1] = i
flag = 0
for elem in D:
	t = D[elem][0]
	p = D[elem][1]
	for i in range(t, p + 1):
		B[i] += 1
for j in range(len(B)):
	if B[j] > k:
		print('YES')
		flag += 1
		break
if flag == 0:
	print('NO')


from sys import stdin, stdout

def main():
	(n, k) = [int(_) for _ in stdin.readline().strip().split()]
	s = stdin.readline().strip()
	last = dict()
	for i in range(26):
		c = chr(ord('A') + i)
		for j in range(n - 1, -1, -1):
			if s[j] == c:
				last[c] = j
				break
	guardAssigned = dict()
	for i in range(26):
		c = chr(ord('A') + i)
		guardAssigned[c] = False
	totalGuard = 0
	maxGuard = 0
	for (i, c) in enumerate(s):
		if not guardAssigned[c]:
			guardAssigned[c] = True
			totalGuard += 1
			maxGuard = max(maxGuard, totalGuard)
		if i == last[c]:
			totalGuard -= 1
	if maxGuard > k:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')
main()


(n, k) = [int(i) for i in input().split()]
a = input()
d = [[n + 1, 0] for i in range(26)]
for i in range(n):
	s = ord(a[i]) - ord('A')
	d[s][0] = min(d[s][0], i)
	d[s][1] = i
ev = []
for i in d:
	if i[0] != n + 1:
		ev.append([i[0], 0])
		ev.append([i[1], 1])
ev.sort()
b = 0
mb = 0
for i in range(len(ev)):
	if ev[i][1] == 1:
		b -= 1
	else:
		b += 1
	mb = max(mb, b)
print(['NO', 'YES'][int(mb > k)])


(n, k) = tuple(map(int, input().split(' ')))
s = input()
start = {}
end = {}
for i in range(n):
	if s[i] not in start:
		start[s[i]] = i
	if s[n - i - 1] not in end:
		end[s[n - i - 1]] = n - i - 1
current = 0
ans = False
for i in range(n):
	if i == start[s[i]]:
		current += 1
	if current > k:
		ans = True
		break
	if i == end[s[i]]:
		current -= 1
	if current > k:
		ans = True
		break
if ans:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
t = input()
k1 = set(t)
d = {}
for i in k1:
	d[i] = (t.index(i), n - t[::-1].index(i) - 1)
s = set()
for i in range(len(t)):
	if i <= d[t[i]][1]:
		s.add(t[i])
	if len(s) > k:
		print('YES')
		exit()
	if i == d[t[i]][1]:
		s.remove(t[i])
print('NO')


def read(is_int, split_by):
	if is_int:
		return [int(x) for x in input().split(split_by)]
	else:
		return [x for x in input().split(split_by)]
(n, k) = map(int, input().split(' '))
s = input()
answer = 'NO'
high = {}
low = {}
all_intersect = []
all_max = []
if k == 26:
	answer = 'NO'
else:
	for i in range(n):
		if not s[i] in low:
			low[s[i]] = i
		high[s[i]] = i
	for key in low:
		all_intersect.append(low[key])
	for key in high:
		all_intersect.append(high[key])
	all_intersect.sort()
	for i in range(len(all_intersect)):
		if all_intersect[i] in low.values():
			if all_max:
				tmp = all_max[len(all_max) - 1]
				tmp += 1
				all_max.append(tmp)
			else:
				all_max.append(1)
		if all_intersect[i] in high.values():
			tmp = all_max[len(all_max) - 1]
			tmp -= 1
			all_max.append(tmp)
	max_elem = max(all_max)
	if max_elem > k:
		answer = 'YES'
	else:
		answer = 'NO'
print(answer)


(n, k) = map(int, input().split())
a = input()
d = {}
for i in range(n):
	d[a[i]] = i
s = set()
for i in range(n):
	s |= {a[i]}
	if len(s) > k:
		break
	if i == d[a[i]]:
		s -= {a[i]}
print('YNEOS'[len(s) <= k::2])


l = [-1] * 122
g = [-1] * 122
r = 0
ch = 0
(n, k) = map(int, input().split())
s = input()
j = n
for i in range(0, n):
	j -= 1
	indf = ord(s[i])
	indb = ord(s[j])
	if l[indf] != -1:
		pass
	else:
		l[indf] = i
	if g[indb] != -1:
		pass
	else:
		g[indb] = j
for i in range(0, n):
	indx = ord(s[i])
	if l[indx] == i:
		r += 1
	if r > k:
		ch = 1
		break
	if g[indx] == i:
		r -= 1
if ch == 1:
	print('YES')
else:
	print('NO')


def main():
	(n, m) = map(int, input().split())
	(s, l) = (input(), [])
	for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
		i = s.find(c)
		if i != -1:
			l += ((i, -1), (s.rfind(c), 1))
	for (_, i) in sorted(l):
		m += i
		if m < 0:
			print('YES')
			return
	print('NO')
main()


(n, k) = input().split()
guests = input()
guests_dict = dict()
for i in range(0, len(guests)):
	guests_dict[guests[i]] = i
k = int(k)
doors = 0
b = set()
for i in range(0, len(guests) - 1):
	b.add(guests[i])
	if len(b) > k:
		print('YES')
		exit()
	if guests_dict[guests[i]] == i:
		b.remove(guests[i])
print('NO')


(n, k) = list(map(int, input().split()))
s = input()
a = [None] * n
d = {}
for i in range(n):
	if s[i] not in d:
		a[i] = 1
		d[s[i]] = True
d.clear()
for i in range(n - 1, -1, -1):
	if s[i] not in d:
		if a[i] is None:
			a[i] = 0
		else:
			a[i] = -1
		d[s[i]] = True
c = 0
for el in a:
	if el is not None and el == 1:
		c += 1
	if el is not None and el == 0:
		c -= 1
	if el is not None and el == -1:
		if c + 1 > k:
			print('YES')
			return
	if c > k:
		print('YES')
		return
print('NO')


(n, k) = map(int, input().split())
ll = input()
d = {}
for i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
	d[i] = 0
for i in ll:
	d[i] += 1
lll = {}
t = True
for i in ll:
	if i not in lll:
		lll[i] = 1
	d[i] -= 1
	if len(lll) > k:
		print('YES')
		t = False
		break
	if d[i] == 0:
		del lll[i]
if t == True:
	print('NO')


(n, k) = map(int, input().split())
s = input()
d = {}
count = {}
for i in range(n):
	if s[i] not in count:
		count[s[i]] = 1
	else:
		count[s[i]] += 1
c = 0
for i in range(n):
	if s[i] not in d:
		d[s[i]] = 1
		c += 1
	else:
		d[s[i]] += 1
	if c > k:
		print('YES')
		exit()
	if d[s[i]] == count[s[i]]:
		del d[s[i]]
		c -= 1
print('NO')


import sys
(n, k) = map(int, input().split())
s = input()
start = {}
close = {}
for i in range(n):
	kk = s[i]
	try:
		a = start[kk]
		close[kk] = i
	except KeyError:
		start[kk] = i
		close[kk] = i
ac = 0
for i in range(n):
	kk = s[i]
	if start[kk] == i:
		ac += 1
		if ac > k:
			print('YES')
			sys.exit(0)
	if close[kk] == i:
		ac -= 1
	if ac > k:
		print('YES')
		sys.exit(0)
print('NO')


import string
import itertools
(n, k) = map(int, input().split())
s = input()
m = max(itertools.accumulate((x[1] for x in sorted([(s.find(let), 1) for let in string.ascii_uppercase if s.find(let) != -1] + [(s.rfind(let), -1) for let in string.ascii_uppercase if s.rfind(let) != -1], key=lambda x: (x[0], -x[1])))))
print(('NO', 'YES')[m > k])


(n, k) = map(int, input().split())
s = input()
d = {}
ans = True
for i in set(s):
	d[i] = s.rfind(i)
cur = set()
for i in range(n):
	if s[i] in cur:
		if d[s[i]] == i:
			cur.remove(s[i])
	else:
		cur.add(s[i])
		if len(cur) > k:
			ans = False
			break
		if d[s[i]] == i:
			cur.remove(s[i])
if ans:
	print('NO')
else:
	print('YES')


import sys
(n, k) = map(int, input().split())
a = list(input())
st = [0] * 26
ed = [0] * 26
for i in range(n):
	if st[ord(a[i]) - 65] == 0:
		st[ord(a[i]) - 65] = i + 1
	else:
		ed[ord(a[i]) - 65] = i + 1
for i in range(26):
	if st[i] != 0 and ed[i] == 0:
		ed[i] = st[i]
n = 52
i = 0
j = 0
maxi = -1 * sys.maxsize
l = 0
st.sort()
ed.sort()
while i < 26 and j < 26:
	if st[i] == 0:
		i += 1
		continue
	if ed[j] == 0:
		j += 1
		continue
	if st[i] <= ed[j]:
		l += 1
		i += 1
		if l > maxi:
			maxi = l
	else:
		l -= 1
		j += 1
if maxi > k:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input().strip()
markings = []
for i in range(n):
	markings.append(0)
characters = set()
for i in range(n - 1, -1, -1):
	if s[i] not in characters:
		characters.add(s[i])
		markings[i] = 1
gates = 0
characters = set()
flag = 0
for i in range(n):
	if s[i] not in characters:
		characters.add(s[i])
		gates += 1
	if gates > k:
		flag = 1
		break
	if markings[i] == 1:
		gates -= 1
if gates > k:
	flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


from collections import deque
from math import *
import heapq
(n, k) = map(int, input().split())
s = input()
d = {}
e = {}
for i in range(len(s)):
	d[s[i]] = i
	e[s[i]] = 0
counter = 0
for j in range(len(s)):
	if d[s[j]] != j and e[s[j]] == 0:
		e[s[j]] = 1
		counter += 1
	elif d[s[j]] == j and e[s[j]] == 0:
		counter += 1
		if counter > k:
			print('YES')
			exit()
		counter -= 1
	elif d[s[j]] == j and e[s[j]] == 1:
		counter -= 1
	if counter > k:
		print('YES')
		exit()
print('NO')


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)
import re

def tup():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]

def debug(*args, c=6):
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=stderr)
from math import log2, sqrt
from collections import defaultdict
from collections import deque
(n, k) = tup()
s = S()
c = k
i = 0
d = set()
di = defaultdict(int)
for i in s:
	di[i] += 1
c = k
gates = set()
d = deque()
i = 0
f = 1
while i < n:
	if s[i] in gates:
		pass
	else:
		gates.add(s[i])
		if len(gates) > k:
			f = 0
			break
	di[s[i]] -= 1
	if di[s[i]] == 0:
		gates.discard(s[i])
	i += 1
if f == 0:
	print('YES')
else:
	print('NO')


(b, c) = ({}, {})
for i in range(ord('A'), ord('Z') + 1):
	(b[chr(i)], c[chr(i)]) = (0, 0)
(n, k) = map(int, input().split())
s = input()
for x in s:
	c[x] += 1
kol = 0
for x in s:
	b[x] += 1
	if b[x] == 1:
		kol += 1
		if kol > k:
			print('YES')
			exit(0)
	if c[x] == b[x]:
		kol -= 1
print('NO')


(n, k) = list(map(int, input().split()))
data = input()
d = {}
c = {}
for i in data:
	if i not in c:
		c[i] = 1
	else:
		c[i] += 1
count = 0
m = 0
for i in data:
	if i not in d:
		count += 1
		d[i] = 1
		m = max(m, count)
		if d[i] == c[i]:
			del d[i]
			count -= 1
	else:
		d[i] += 1
		if d[i] == c[i]:
			del d[i]
			count -= 1
if m <= k:
	print('NO')
else:
	print('YES')


from collections import Counter

def main():
	(n, k) = map(int, input().split())
	s = input()
	ocnt = Counter(s)
	cnt = ocnt.copy()
	i = 0
	for e in s:
		if cnt[e] == ocnt[e]:
			i += 1
			if i > k:
				print('YES')
				return
		cnt[e] -= 1
		if cnt[e] == 0:
			i -= 1
	print('NO')
main()


(n, k) = map(int, input().split())
s = input()
our = set()
opened = set()
for i in range(ord('A'), ord('Z') + 1):
	sym = chr(i)
	if sym in s:
		our.add(s.rfind(sym))
for i in range(len(s)):
	if s[i] not in opened:
		opened.add(s[i])
		k -= 1
		if k < 0:
			print('YES')
			return
	if i in our:
		k += 1
print('NO')


(n, k) = map(int, input().split())
s = input()
last = {}
for i in range(len(s)):
	last[s[i]] = i
opened = 0
op = set()
for i in range(len(s)):
	l = s[i]
	if l not in op:
		op.add(l)
	if len(op) > k:
		print('YES')
		exit()
	if last[l] == i:
		op.remove(l)
print('NO')


from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split())
s = stdin.readline().rstrip()
count1 = [0] * 26
count2 = [0] * 26
for i in s:
	count1[ord(i) - ord('A')] += 1
doorsOpen = 0
maxDoorOpen = 0
for i in s:
	count2[ord(i) - ord('A')] += 1
	if count2[ord(i) - ord('A')] == 1:
		doorsOpen += 1
		maxDoorOpen = max(maxDoorOpen, doorsOpen)
	if count2[ord(i) - ord('A')] == count1[ord(i) - ord('A')]:
		doorsOpen -= 1
if maxDoorOpen > k:
	stdout.write('YES')
else:
	stdout.write('NO')


from collections import Counter
(n, k) = list(map(int, input().split()))
s = input()
s1 = Counter(s)
(a, c) = (0, 0)
d = {}
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
		c += 1
	a = max(a, c)
	if d[i] == s1[i]:
		c -= 1
print('YES' if a > k else 'NO')


from collections import deque
(n, k) = list(map(int, input().split()))
s = input()
rs = s[::-1]
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
last = {}
for c in alpha:
	p = rs.find(c)
	if p != -1:
		last.update({c: n - p - 1})
amount = 0
o = deque()
c = 0
for i in range(len(s)):
	if s[i] not in o:
		o.append(s[i])
		c += 1
	if c > k:
		print('YES')
		break
	if i == last[s[i]]:
		c -= 1
else:
	print('NO')


(n, k) = [int(i) for i in input().strip().split()]
g_l = input().strip()
closing_i = dict()
is_closing = [False for i in range(n)]
for i in range(n):
	i = n - i - 1
	if g_l[i] not in closing_i:
		closing_i[g_l[i]] = i
		is_closing[i] = True
open_d = dict()
cur_open = 0
g_open = 0
for i in range(n):
	if g_l[i] not in open_d:
		open_d[g_l[i]] = True
		cur_open += 1
		g_open = max(cur_open, g_open)
	if is_closing[i]:
		cur_open -= 1
if g_open > k:
	print('YES')
else:
	print('NO')


(n, k) = [int(x) for x in input().split()]
guests = list(input())
doors = dict()
gt = dict()
opened = 0
f = True
for u in guests:
	gt[u] = gt.get(u, 0) + 1
for i in guests:
	if i not in doors:
		doors[i] = 1
		opened += 1
	else:
		doors[i] += 1
	if opened > k:
		print('YES')
		f = False
		break
	if doors[i] == gt[i]:
		opened -= 1
if f:
	print('NO')


(n, k) = map(int, input().split(' '))
inter = input()
d = {}
for i in range(26):
	d[chr(65 + i)] = [-1, -1]
for i in range(len(inter)):
	if d[inter[i]][0] == -1:
		d[inter[i]][0] = d[inter[i]][1] = i
	else:
		d[inter[i]][1] = i

def interect(a, b):
	return not (b[0] >= a[1] or b[1] <= a[0])

def getIntersection(a, b):
	return [max(a[0], b[0]), min(a[1], b[1])]
maxIntersections = 0
for i in range(26):
	(inters, interval) = (0, d[chr(65 + i)])
	for j in range(26):
		if interect(interval, d[chr(65 + j)]):
			inters += 1
			interval = getIntersection(interval, d[chr(65 + j)])
	maxIntersections = max(maxIntersections, inters - 1)
print('YES' if maxIntersections >= k else 'NO')


(n, k) = [int(i) for i in input().split()]
s = input().strip()
s = list(s)
l = []
l1 = []
for i in range(26):
	l1.append(0)
	l.append(0)
for i in s:
	l[ord(i) - 65] += 1
f = 0
l1[ord(s[0]) - 65] = 1
count = 1
for i in s:
	if count == k and l1[ord(i) - 65] == 0:
		print('YES')
		f = 1
		break
	l[ord(i) - 65] -= 1
	if l[ord(i) - 65] > 0:
		if l1[ord(i) - 65] != 1:
			l1[ord(i) - 65] = 1
			count += 1
	elif l1[ord(i) - 65] != 0:
		l1[ord(i) - 65] = 0
		count -= 1
	if count > k:
		print('YES')
		f = 1
		break
if f == 0:
	print('NO')


from math import inf, sqrt, floor, ceil
from collections import Counter, defaultdict, deque
from heapq import heappush as hpush, heappop as hpop, heapify as h
from operator import itemgetter
from itertools import product
from bisect import bisect_left, bisect_right
(n, k) = map(int, input().split())
s = input()
last = Counter()
for i in range(n):
	last[s[i]] = i
first = set()
ans = 'NO'
for i in range(n):
	if s[i] not in first:
		first.add(s[i])
	if len(first) > k:
		ans = 'YES'
		break
	if last[s[i]] == i:
		first.discard(s[i])
print(ans)


(n, k) = map(int, input().split())
s = input()
(Open, Close) = ([-1 for i in range(26)], [-1 for i in range(26)])
ope = 0
Bool = True
for i in range(n):
	curr = ord(s[i]) - ord('A')
	if Open[curr] == -1:
		Open[curr] = i
		Close[curr] = i
	else:
		Close[curr] = i
for i in range(n):
	if i in Open:
		ope += 1
	if ope > k:
		Bool = False
		break
	if i in Close:
		ope -= 1
print('NO') if Bool else print('YES')


def PS():
	uOutput = 0
	uInput = int(input())
	if uInput % 2 == 0:
		bQuart = 0
		if uInput % 4 == 0:
			bQuart = 1
		uHalf = uInput // 2
		uOutput = uHalf // 2 - bQuart
	return uOutput

def GetDoorIndex(c):
	return ord(c) - ord('A')
uOpen_Num = 0
uList_DoorOpen = [False] * 26

def OpenDoor(c):
	global uOpen_Num
	global uList_DoorOpen
	index = GetDoorIndex(c)
	uList_DoorOpen[index] = True
	uOpen_Num += 1

def CloseDoor(c):
	global uOpen_Num
	global uList_DoorOpen
	index = GetDoorIndex(c)
	uList_DoorOpen[index] = False
	uOpen_Num -= 1

def FE():
	global uOpen_Num
	global uList_DoorOpen
	uList_Guest = [0] * 26
	uOutput = 'NO'
	sInput = input()
	sGuest = input()
	sInput_List = sInput.split(' ')
	uGuest_Num = int(sInput_List[0])
	uGuard_Num = int(sInput_List[1])
	for c in sGuest:
		index = GetDoorIndex(c)
		uList_Guest[index] += 1
	uGuest_Counter = 0
	uDoorIndex = 0
	for c in sGuest:
		uDoorIndex = GetDoorIndex(c)
		uList_Guest[uDoorIndex] -= 1
		if uList_DoorOpen[uDoorIndex]:
			if uList_Guest[uDoorIndex] <= 0:
				CloseDoor(c)
			else:
				pass
		else:
			if uOpen_Num >= uGuard_Num:
				uOutput = 'YES'
				break
			if uList_Guest[uDoorIndex] > 0:
				OpenDoor(c)
			else:
				pass
		uGuest_Counter += 1
	print(uOutput)
FE()


(guest, guard) = [int(x) for x in input().strip().split(' ')]
list = [x for x in input().strip()]
first = {}
last = {}
for (i, c) in enumerate(list):
	if c not in first:
		first[c] = i
	last[c] = i
posCount = []
current = 0
for (i, c) in enumerate(list):
	if first[c] == i:
		current += 1
	posCount.append(current)
	if last[c] == i:
		current -= 1
if max(posCount) > guard:
	print('yes')
else:
	print('no')


(n, k) = map(int, input().split())
s = input()
d = {}
op = set()
for i in range(len(s)):
	d[s[i]] = i
ans = 0
doors = 0
for i in range(len(s)):
	if s[i] not in op:
		doors += 1
		op.add(s[i])
	ans = max(ans, doors)
	if i == d[s[i]]:
		doors -= 1
print(('YES', 'NO')[ans <= k])


import sys
input = sys.stdin.readline

def main():
	(n, k) = map(int, input().split())
	guests = input().rstrip()
	guestbook = {}
	for (idx, guest) in enumerate(guests):
		if guest not in guestbook:
			guestbook[guest] = (idx, idx)
		else:
			val = guestbook[guest]
			guestbook[guest] = (val[0], idx)
	timeline = [0] * n
	for timings in guestbook.values():
		for idx in range(timings[0], timings[1] + 1):
			timeline[idx] += 1
	print('YES') if max(timeline) > k else print('NO')
main()


(n, k) = map(int, input().split())
g = input().encode()
e = [-1] * 26
for i in range(n):
	e[g[i] - 65] = i
curS = 0
f = 1
met = [0] * 26
for i in range(n):
	if not met[g[i] - 65]:
		curS += 1
		met[g[i] - 65] = 1
	if curS > k:
		f = 0
		break
	if i == e[g[i] - 65]:
		curS -= 1
print('NO' if f else 'YES')


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = False
testingMode = False
optimiseForReccursion = False

def main():
	(n, k) = get_tuple()
	li = list(input())
	s_indexes = [-1 for _ in range(26)]
	end_indexes = [-1 for _ in range(26)]
	for (i, ele) in enumerate(li):
		end_indexes[ord(ele) - 65] = i
	c = Counter(end_indexes)
	open = set()
	open_count = 0
	for (i, ele) in enumerate(li):
		if ele not in open:
			open.add(ele)
			open_count += 1
			if open_count > k:
				print('YES')
				return
		if i in c:
			open_count -= c[i]
	print('NO')
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


(n, k) = map(int, input().split())
s = str(input())
f = [[0] * 26 for j in range(2)]
for i in range(26):
	aa = s.find(chr(65 + i))
	bb = s.rfind(chr(65 + i))
	f[0][i] = aa
	f[1][i] = bb
lmin = max(f[0])
ans = 0
for i in range(26):
	if f[1][i] >= lmin:
		ans += 1
if ans <= k:
	print('NO')
else:
	print('YES')


arr = list(map(int, input().split()))
total_g = arr[0]
guards = arr[1]
close_gate = dict()
entry = input()
changes = 0
for i in range(0, total_g):
	if entry[i] in close_gate:
		close_gate[entry[i]] = close_gate[entry[i]] + 1
	else:
		close_gate[entry[i]] = 1
cnt_gate = dict()
avg = guards
flag = 0
for i in range(0, total_g):
	if entry[i] not in cnt_gate:
		if avg == 0 and i != 0 and (cnt_gate[entry[i - 1]] != close_gate[entry[i - 1]]):
			print('YES')
			flag = 1
			break
		cnt_gate[entry[i]] = 1
		avg = avg - 1
		if cnt_gate[entry[i]] == close_gate[entry[i]]:
			avg = avg + 1
	else:
		cnt_gate[entry[i]] = cnt_gate[entry[i]] + 1
		if cnt_gate[entry[i]] == close_gate[entry[i]]:
			avg = avg + 1
if flag == 0:
	print('NO')


import sys
(n, k) = map(int, input().split())
s = input()
lp = {}
act = set()
for i in range(n):
	lp[s[i]] = i
for i in range(n):
	act.add(s[i])
	if len(act) > k:
		print('YES')
		sys.exit()
	elif lp[s[i]] == i:
		act.remove(s[i])
print('NO')


from collections import Counter
first = input()
(n, k) = first.split()
n = int(n)
k = int(k)
second = input()
guests = Counter(second)
guarded = set()
resv = k
flag = 1
for i in range(n):
	if second[i] not in guarded:
		if resv > 0:
			guarded.add(second[i])
			resv -= 1
		else:
			flag = 0
			break
	guests[second[i]] -= 1
	if guests[second[i]] == 0:
		resv += 1
		guarded.remove(second[i])
if flag == 0:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
arr = dict()
arr_ = dict()
ans = 'NO'
for i in range(65, 91):
	arr[chr(i)] = 0
	arr_[chr(i)] = 0
for i in s:
	arr_[i] += 1
for i in s:
	if arr[i] == 0:
		k -= 1
	arr[i] += 1
	if k < 0:
		ans = 'YES'
	if arr[i] == arr_[i]:
		k += 1
print(ans)


(n, k) = map(int, input().split())
l = list(input())
d = {}
for i in range(n):
	d[l[i]] = [0, i]
ac = 0
for i in range(n):
	if d[l[i]][0] == 0:
		ac += 1
		d[l[i]][0] = 1
	if ac > k:
		print('YES')
		break
	if d[l[i]][1] == i:
		ac -= 1
else:
	print('NO')


(n, k) = map(int, input().split(' '))
order = list(input())
order_rev = order[::-1]
allbits = set(order)
opengate = list()
closegate = list()
for ele in allbits:
	j = order.index(ele)
	opengate.append(j)
	closegate.append(len(order) - order_rev.index(ele) - 1)
opened = 0
closegate.sort()
i = 0
j = 0
while i < len(opengate):
	if opengate[i] <= closegate[j]:
		opened += 1
		i += 1
	else:
		opened -= 1
		j += 1
	if opened > k:
		print('YES')
		exit()
print('NO')


(n, k) = map(int, input().strip().split())
s = input()
pos = {}
for (idx, c) in enumerate(s, 0):
	pos[c] = idx
unwanted_quests = False
active = set()
for (idx, c) in enumerate(s, 0):
	if pos[c] >= idx:
		active.add(c)
	if len(active) > k:
		unwanted_quests = True
		break
	if pos[c] == idx and c in active:
		active.remove(c)
if unwanted_quests:
	print('YES')
else:
	print('NO')


(guests, guards) = map(int, input().split())
doors = input()
dict = {}
set = set()
for i in range(guests):
	dict[doors[i]] = i
for j in range(guests):
	set.add(doors[j])
	if len(set) > guards:
		print('YES')
		break
	if j == dict[doors[j]]:
		set.remove(doors[j])
if len(set) <= guards:
	print('NO')


(n, k) = map(int, input().split())
s = input()
flag = False
last_pos = {}
gate = set()
for i in range(len(s)):
	last_pos[s[i]] = i
for i in range(len(s)):
	gate.add(s[i])
	if len(gate) > k:
		flag = True
		break
	if last_pos[s[i]] == i:
		gate.remove(s[i])
if flag:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
dic = dict()
d = {}
for i in set(s):
	dic[i] = s.rfind(i)
	d[i] = 1
o = 0
for i in range(len(s)):
	if d[s[i]]:
		o += 1
		if o > k:
			print('yes')
			exit()
		d[s[i]] = 0
	if i == dic[s[i]]:
		o -= 1
print('no')


(n, k) = map(int, input().split())
guests = input()
(guest_dict, guest_set) = ({}, set())
for i in range(n):
	guest_dict[guests[i]] = i
for i in range(n):
	guest_set.add(guests[i])
	if len(guest_set) > k:
		print('YES')
		break
	if i == guest_dict[guests[i]]:
		guest_set.remove(guests[i])
if len(guest_set) <= k:
	print('NO')


(n, k) = map(int, input().split())
G = list(input())
g = []
e = [-1] * 91
for i in range(n):
	g.append(ord(G[i]))
	e[g[i]] = i
curS = 0
f = 1
met = [0] * 91
for i in range(n):
	if not met[g[i]]:
		curS += 1
		met[g[i]] = 1
	if curS > k:
		f = 0
		break
	if i == e[g[i]]:
		curS -= 1
if f:
	print('NO')
else:
	print('YES')


(n, k) = map(int, input().split())
doors = input()
close_i = {}
opened = set()
for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
	close_i[c] = doors.rfind(c)
guards = 0
for (i, d) in enumerate(doors):
	if i == close_i[d]:
		if d in opened:
			opened.remove(d)
			guards -= 1
		elif guards + 1 > k:
			print('YES')
			break
		continue
	if d not in opened:
		opened.add(d)
		guards += 1
		if guards > k:
			print('YES')
			break
else:
	print('NO')


from sys import stdin
OPEN = True
CLOSE = False
try:
	while True:
		doors = dict(((c, CLOSE) for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'))
		(guests, guards) = tuple(map(int, input().split(' ', 2)))
		entries = input()
		close_door = dict(((c, entries.rfind(c)) for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'))
		if guards >= len(doors):
			print('NO')
			continue
		if len(set(entries)) <= guards:
			print('NO')
			continue
		total_open = 0
		for (index, door) in enumerate(entries):
			if doors[door] == CLOSE:
				doors[door] = OPEN
				total_open += 1
			if total_open > guards:
				break
			if close_door[door] == index:
				doors[door] = CLOSE
				total_open -= 1
		if total_open > guards:
			print('YES')
		else:
			print('NO')
except EOFError:
	pass


first_line = input().strip()
n = int(first_line.split()[0])
k = int(first_line.split()[1])
n_line = input().strip()
guest_doors = []
door_dict = {}
for x in range(n):
	if n_line[x] in door_dict:
		if len(door_dict[n_line[x]]) > 1:
			door_dict[n_line[x]][1] = x
		else:
			door_dict[n_line[x]].append(x)
	else:
		door_dict[n_line[x]] = []
		door_dict[n_line[x]].append(x)
start_end = []
for key in door_dict:
	if door_dict[key][0] == door_dict[key][-1]:
		start_end.append([door_dict[key][0], 'd'])
	else:
		start_end.append([door_dict[key][0], 's'])
		start_end.append([door_dict[key][-1], 'f'])
max_conflicts = -1
conflicts = 0
sorted_vals = sorted(start_end)
for x in sorted_vals:
	if x[1] == 's':
		conflicts += 1
	elif x[1] == 'f':
		conflicts -= 1
	elif x[1] == 'd':
		conflicts += 1
	if conflicts > max_conflicts:
		max_conflicts = conflicts
	if x[1] == 'd':
		conflicts -= 1
if k >= max_conflicts:
	print('NO')
else:
	print('YES')


from collections import defaultdict
(n, k) = map(int, input().split())
s = input()
d = defaultdict(lambda : [-1, -1])
s1 = s[::-1]
for x in range(65, 91):
	if s.find(chr(x)) != -1:
		d[chr(x)][0] = s.find(chr(x))
		d[chr(x)][1] = n - 1 - s1.find(chr(x))
t = s[0]
k1 = 1
f = 0
for x in range(1, n):
	if s[x] != t and d[s[x - 1]][1] != x - 1 and (d[s[x]][0] == x):
		k1 += 1
		if k1 > k:
			f = 1
			break
	elif d[s[x]][0] != x and d[s[x - 1]][1] == x - 1:
		k1 -= 1
	t = s[x]
if f:
	print('YES')
else:
	print('NO')


from collections import namedtuple
Segment = namedtuple('Segment', 'coor sign')
(n, k) = map(int, input().split())
s = input()
board = []
s_set = set(s)
for c in s_set:
	board.append(Segment(s.find(c), 1))
	board.append(Segment(s.rfind(c), -1))
cnt = 0
for x in sorted(board, key=lambda x: x.coor):
	cnt += x.sign
	if cnt > k:
		print('YES')
		exit(0)
print('NO')


(n, k) = map(int, input().split(' '))
s = input()
last_pos = {}
active = set()
for i in range(n):
	last_pos[s[i]] = i
for i in range(n):
	active.add(s[i])
	if len(active) > k:
		print('YES')
		exit()
	if last_pos[s[i]] == i:
		active.remove(s[i])
print('NO')


from sys import stdin
(n, k) = map(int, input().strip().split(' '))
s = stdin.readline().rstrip()
sum_hash = [0 for _ in range(26)]
cur_hash = [0 for _ in range(26)]
for c in s:
	sum_hash[ord(c) - ord('A')] += 1
printyes = False
guard_need = 0
for c in s:
	if cur_hash[ord(c) - ord('A')] == 0:
		guard_need += 1
	if guard_need > k:
		printyes = True
	cur_hash[ord(c) - ord('A')] += 1
	if cur_hash[ord(c) - ord('A')] == sum_hash[ord(c) - ord('A')]:
		guard_need -= 1
if printyes:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = str(input())
m = {}
z = set()
for (i, t) in enumerate(s):
	m[t] = i
for (i, t) in enumerate(s):
	if m[t] != i:
		z.add(t)
		if len(z) > k:
			print('YES')
			exit()
	elif t in z:
		z.remove(t)
	elif len(z) + 1 > k:
		print('YES')
		exit()
print('NO')


temp = input().split(' ')
n = int(temp[0])
k = int(temp[1])
s = input()
alphabet = set(s)
starts = []
ends = []
for x in alphabet:
	starts.append(s.index(x))
	ends.append(s.rindex(x))
res = 0
for x in starts:
	count = 0
	for y in starts:
		if y < x:
			count += 1
	for y in ends:
		if y < x:
			count -= 1
	if count >= k:
		res = 1
if res:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()

def solve():
	(n, k) = I()
	s = I1().strip()
	d = {}
	for x in s:
		d[x] = d.get(x, 0) + 1
	SET = set()
	for i in range(n):
		if s[i] in SET:
			d[s[i]] -= 1
			if d[s[i]] == 0:
				SET.remove(s[i])
		elif k > len(SET):
			SET.add(s[i])
			d[s[i]] -= 1
			if d[s[i]] == 0:
				SET.remove(s[i])
		else:
			break
	if len(SET) == 0:
		print('NO')
	else:
		print('YES')
solve()


X = list(map(int, input().split()))
Entrance = input()
(MyDict, Visit) = ({}, [])
for i in range(X[0]):
	if Entrance[i] not in MyDict.keys():
		MyDict[Entrance[i]] = []
	MyDict[Entrance[i]].append(i)
i = 0
while i < X[0]:
	if Entrance[i] not in Visit:
		if X[1] == 0:
			print('YES')
			exit()
		X[1] -= 1
		Visit.append(Entrance[i])
	if MyDict[Entrance[i]][-1] == i:
		X[1] += 1
	i += 1
print('NO')


read = lambda : map(int, input().split())
(n, k) = read()
s = input()
ev = []
for i in range(26):
	c = chr(ord('A') + i)
	if s.count(c):
		l = s.find(c)
		r = s.rfind(c)
		ev.append((l, 1))
		ev.append((r, -1))
ev.sort(key=lambda x: (x[0], -x[1]))
bal = 0
flag = 0
for (x, t) in ev:
	bal += t
	if bal > k:
		flag = 1
		break
print('YES' if flag else 'NO')


import io, os

def main():
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
	(n, k) = map(int, input().split())
	(g, e) = ([x - 65 for x in input()], [-1] * 26)
	for i in range(n):
		e[g[i]] = i
	(curS, met) = (0, [0] * 26)
	for i in range(n):
		if not met[g[i]]:
			curS += 1
			met[g[i]] = 1
		if curS > k:
			os.write(1, b'YES')
			exit()
		if i == e[g[i]]:
			curS -= 1
	os.write(1, b'NO')
main()


(n, k) = map(int, input().split())
s = input()
d = {}
for i in range(len(s)):
	try:
		if len(d[s[i]]) == 2:
			d[s[i]][1] = i
			continue
		d[s[i]].append(i)
	except:
		d[s[i]] = []
		d[s[i]].append(i)
l = []
for ele in d.values():
	l.append([ele[0], 0])
	l.append([ele[-1], 1])
l.sort()
cnt = 0
ans = 0
for ele in l:
	if ele[1] == 0:
		cnt += 1
	if ele[1] == 1:
		cnt -= 1
	ans = max(cnt, ans)
if ans > k:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
st = input()
ans = True
count = 0
stat = {}
last = {}
for i in range(n):
	last[st[i]] = i
	stat[st[i]] = False
for i in range(n):
	if stat[st[i]] == False:
		stat[st[i]] = True
		count += 1
	if count > k:
		ans = False
		break
	if last[st[i]] == i:
		count -= 1
if ans == True:
	print('NO')
else:
	print('YES')


from sys import stdin, stdout

def rint():
	return list(map(int, stdin.readline().split()))
(n, k) = rint()
s = input()
sl = {}
for i in range(len(s)):
	if not s[i] in sl:
		sl[s[i]] = [i, i]
	else:
		sl[s[i]][1] = i
cnt = 0
for i in range(len(s)):
	if sl[s[i]][0] == i:
		cnt += 1
	if cnt > k:
		print('YES')
		return
	if sl[s[i]][1] == i:
		cnt -= 1
print('NO')


from sys import stdin
inp = stdin.readline
(n, k) = map(int, inp().split())
s = inp()[:-1]
out_time = [-1] * 26
in_time = [-1] * 26
for i in range(n):
	if in_time[ord(s[i]) - ord('A')] == -1:
		in_time[ord(s[i]) - ord('A')] = i
for i in range(n - 1, -1, -1):
	if out_time[ord(s[i]) - ord('A')] == -1:
		out_time[ord(s[i]) - ord('A')] = i
requirement = [0] * (n + 1)
for i in range(26):
	if in_time[i] != -1:
		requirement[in_time[i]] += 1
		requirement[out_time[i] + 1] -= 1
cur_sum = 0
for i in range(n):
	cur_sum += requirement[i]
	requirement[i] = cur_sum
print('NO' if max(requirement) <= k else 'YES')


def main(n, k, s):
	last = {}
	for i in range(n - 1, -1, -1):
		j = ord(s[i]) - ord('A')
		if j not in last:
			last[j] = i
	se = set()
	for (i, c) in enumerate(list(map(lambda i: ord(i) - ord('A'), s))):
		if c not in se:
			se.add(c)
		if len(se) > k:
			return 'YES'
		if i == last[c]:
			se.remove(c)
	return 'NO'
print(main(*list(map(int, input().split(' '))), input()))


def main():
	(n, k) = [int(n) for n in input().split()]
	S = input()
	doors = {}
	for (i, s) in enumerate(S):
		doors[s] = i
	activeDoors = set()
	for (i, s) in enumerate(S):
		if doors[s] == i:
			activeDoors.add(s)
			if len(activeDoors) > k:
				return 'YES'
			activeDoors.remove(s)
		else:
			activeDoors.add(s)
			if len(activeDoors) > k:
				return 'YES'
	return 'NO'
print(main())


import string
import sys

def main():
	iterator = iter(sys.stdin.read().split())
	(n, m) = (int(next(iterator)), int(next(iterator)))
	s = next(iterator)
	p = {}
	buffer = set()
	for i in string.ascii_uppercase:
		p[i] = s.rfind(i)
	for (i, x) in enumerate(s):
		buffer.add(x)
		if len(buffer) > m:
			print('YES')
			return
		if i == p[x]:
			buffer.remove(x)
	print('NO')
main()


import sys, os
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
(n, door) = map(int, input().split())
s = input()
active_door = set()
last_pos = {}
for i in range(n):
	last_pos[s[i]] = i
for i in range(n):
	active_door.add(s[i])
	if len(active_door) > door:
		print('YES')
		exit()
	if last_pos[s[i]] == i:
		active_door.remove(s[i])
print('NO')


(n, k) = map(int, input().split())
s = input()
st = [float('inf')] * 26
ed = [float('-inf')] * 26
for (i, c) in enumerate(s):
	ct = ord(c) - ord('A')
	st[ct] = min(st[ct], i)
	ed[ct] = max(ed[ct], i)
b = [0] * (n + 1)
for i in range(26):
	if st[i] < float('inf'):
		b[st[i]] += 1
		b[ed[i] + 1] -= 1
for i in range(n):
	if i:
		b[i] += b[i - 1]
	if b[i] > k:
		print('YES')
		exit()
print('NO')


from collections import Counter

def main():
	(n, k) = map(int, input().split())
	queue = input()
	counter = Counter()
	unique = list(set(queue))
	amount = dict(zip(unique, [queue.count(x) for x in unique]))
	for x in queue:
		counter[x] += 1
		if len(counter) > k:
			return 'Yes'
		if counter[x] == amount[x]:
			counter.pop(x)
	return 'NO'
print(main())


from time import time
(n, k) = map(int, input().split())
g = input()
e = [-1] * 26
for i in range(n):
	e[ord(g[i]) - 65] = i
curS = 0
f = 1
met = [0] * 26
for i in range(n):
	if not met[ord(g[i]) - 65]:
		curS += 1
		met[ord(g[i]) - 65] = 1
	if curS > k:
		f = 0
		break
	if i == e[ord(g[i]) - 65]:
		curS -= 1
if f:
	print('NO')
else:
	print('YES')


import sys
input = sys.stdin.readline

def main():
	(n, k) = map(int, input().split())
	guests = input().rstrip()
	guestbook = {guest: idx for (idx, guest) in enumerate(guests)}
	s = set()
	for (idx, guest) in enumerate(guests):
		if guest not in s:
			s.add(guest)
		if len(s) > k:
			print('YES')
			return
		if guestbook[guest] == idx:
			s.remove(guest)
	print('NO')
main()


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial
INT_MIN = float('-infinity')
INT_MAX = float('infinity')
(n, k) = map(int, input().split())
flag = 'NO'
d = set()
z = {}
s = input()
for i in range(n):
	z[s[i]] = i
for i in range(n):
	d.add(s[i])
	if len(d) > k:
		flag = 'YES'
		break
	if z[s[i]] == i:
		d.remove(s[i])
print(flag)


(n, k) = map(int, input().split())
l = set()
d = dict()
s = input()
f = 'NO'
for i in range(n):
	d[s[i]] = i
for i in range(n):
	l.add(s[i])
	if len(l) > k:
		f = 'YES'
		break
	if d[s[i]] == i:
		l.remove(s[i])
print(f)


(n, k) = [int(x) for x in input().split()]
s = input()
all_bad = 'NO'
alphabet = set(s)
doors = []
for letter in alphabet:
	doors.append((s.find(letter), s.rfind(letter)))
starts = [doors[i][0] for i in range(len(alphabet))]
stops = [doors[i][1] for i in range(len(alphabet))]
for elem in starts:
	if len([x for x in starts if x < elem]) - len([x for x in stops if x < elem]) >= k:
		all_bad = 'YES'
print(all_bad)


from sys import stdin

def unguarded_door(n, k, entrances):
	last_occurence = {}
	nb_guarded_doors = [0] * n
	potential_nb = 0
	for i in range(n):
		entrance = entrances[i]
		if entrance not in last_occurence:
			potential_nb += 1
		last_occurence[entrance] = i
		nb_guarded_doors[i] = potential_nb
	for i in last_occurence.values():
		nb_guarded_doors[i + 1:] = [nb - 1 for nb in nb_guarded_doors[i + 1:]]
	for nb in nb_guarded_doors:
		if nb > k:
			return 'YES'
	return 'NO'
(n, k) = [int(c) for c in stdin.readline().split(' ')]
entrances = stdin.readline()
print(unguarded_door(n, k, entrances))


(n, k) = (int(i) for i in input().split())
s = input()
a = [0] * n
b = []
x = k
y = 0
alf = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
end = [s.rfind(i) for i in alf]
begin = [s.find(i) for i in alf]
f = False
ans = False
for i in range(n):
	find = alf.find(s[i])
	if i != end[find] and (not s[i] in b) or begin[find] == end[find]:
		b.append(s[i])
		x -= 1
	elif i == end[find] and i != begin[find]:
		x += 1
	if x < 0:
		ans = True
		break
	if begin[find] == end[find]:
		x += 1
print('YES' if ans else 'NO')


(N, A) = map(int, input().split())
S = str(input())
Dee = [[] for i in range(0, 26)]
Ree = [0] * (N + 1)
for i in range(0, N):
	Dee[ord(S[i]) - 65].append(i)
for i in range(0, 26):
	if len(Dee[i]) > 0:
		Ree[Dee[i][0]] += 1
		Ree[Dee[i][-1] + 1] -= 1
for i in range(1, N + 1):
	Ree[i] += Ree[i - 1]
for i in range(0, N):
	if Ree[i] > A:
		print('YES')
		exit()
print('NO')


import heapq

def doIt(s):
	for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
		if c in s:
			(a, b) = (s.rfind(c), s.find(c))
			heapq.heappush(end, a)
			heapq.heappush(start, b)
	current = 0
	while start:
		if start[0] <= end[0]:
			heapq.heappop(start)
			current += 1
			if current > k:
				return 'YES'
		else:
			heapq.heappop(end)
			current -= 1
	return 'NO'
(n, k) = map(int, input().split())
s = input()
start = []
end = []
print(doIt(s))


import os
from io import BytesIO

def main():
	input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
	(n, k) = map(int, input().split())
	g = input()
	e = [-1] * 100
	for (i, c) in enumerate(g):
		e[c] = i
	curS = 0
	f = 1
	met = [0] * 100
	for (i, c) in enumerate(g):
		if not met[c]:
			curS += 1
			met[c] = 1
		if curS > k:
			print('YES')
			break
		if i == e[c]:
			curS -= 1
	else:
		print('NO')
main()