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

r = list(range(A, B+1))
for i in sorted(set(r[:K] + r[-K:])):
    print(i)


### FIXED CODE ###

a,b,k=map(int,input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):print(i)
import math
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
q = int(math.sqrt(n))+1
sum = 0
for i in range(1,q):
    ddprint("i {}".format(i))
    if n%i==0:
        m = n//i - 1
        ddprint("divides m {}".format(m))
        if n%m == n//m:
            sum += m
print(sum)


### FIXED CODE ###

import math
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
q = int(math.sqrt(n))+1
sum = 0
for i in range(1,q):
    ddprint("i {}".format(i))
    if n%i==0:
        m = n//i - 1
        ddprint("divides m {}".format(m))
        if m==0:
            continue
        if n%m == n//m:
            sum += m
print(sum)
from collections import Counter
from itertools import combinations
from functools import lru_cache
@lru_cache(maxsize=None)

def kaijou(n):
    if n <= 1:
        return 1
    return kaijou(n-1)*n

def comb(n,m):
    return int(kaijou(n)/kaijou(m)/kaijou(n-m))

n = int(input())
a = list(map(int,input().split()))
A = [0]
for i in a:
    A.append(A[-1]+i)
ans = 0
B = Counter(A)
for i in B.values():
    if i >= 2:
        ans += comb(i,2)
print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
A = [0]
for i in map(int,input().split()):
    A.append(A[-1]+i)
ans = 0
B = Counter(A)
for i in B.values():
    if i >= 2:
        ans += int(i*(i-1)/2)
print(ans)
import numpy as np

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

l = [int(i) for i in input().split()]
l.sort()
if n == 1 or m == 1 or m == 2:
    print(l[-1]-l[0])
else:
    d = [0 for i in range(m - 1)]
    for i in range(m-1):
        d[i] = l[i+1] - l[i]
    d = np.array(d)
    dl = d.argsort()[::-1]
    count = 0
    for i in range(n):
        if i == 0:
            count += l[dl[i]] - l[0]
            index = dl[i]
        elif i == n - 1:
            count += l[-1] - l[index+1]
        else:
            count += l[dl[i]] - l[index+1]
            index = dl[i]
    print(count)


### FIXED CODE ###

import numpy as np

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

l = [int(i) for i in input().split()]
l.sort()
if n == 1 or m == 1:
    print(l[-1]-l[0])
elif n > m:
    print(0)
else:
    d = [0 for i in range(m - 1)]
    for i in range(m-1):
        d[i] = l[i+1] - l[i]
    d = np.array(d)
    dl = d.argsort()[::-1]
    count = 0
    for i in range(n):
        if i == 0:
            count += l[dl[i]] - l[0]
            index = dl[i]
        elif i == n - 1:
            count += l[-1] - l[index+1]
        else:
            count += l[dl[i]] - l[index+1]
            index = dl[i]
    print(count)
n = int(input())
h = list(map(int, input().split()))
max_h = 0
ans = 0
for a in h:
  if max <= a:
    ans += 1
  max_h = max(a, max_h)
  
print(ans)

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
max_h = 0
ans = 0
for a in h:
  if max_h <= a:
    ans += 1
  max_h = max(a, max_h)
  
print(ans)
li=[]
n=int(input())
while True:
    try:
        li.append(list(map(int,input().split())))
    except:
        break
if li[i][1]<0 or li[i][2]<0 for i in range(n):
    print('NO')
else:
    nl=li[:][1,2]
    for j in range(n-1):
        d=nl[j+1][:]-nl[j][:]
        if not d==[1,0] or [0,1] or [-1,0] or [0,-1]:
            print('NO')
            break
    print('YES')

### FIXED CODE ###

n=int(input())
li=[]
while True:
    try:
        li.append(list(map(int,input().split())))
    except:
        break

#ans=Trueにしておいて、チェックにひっ掛かったらFalseに変える
ans=True

#設定より負の値になっていればNO
for i in range(n):
    if li[i][1]>=0 and li[i][2]>=0:
        continue
    ans=False
    print('No')
    break
        
        
#進める最大値よりも先に存在した場合にNOを出す
if ans==True:
    for j in range(n):
        if li[j][0]>=li[j][1]+li[j][2]:
            continue
        ans=False
        print('No')
        break
#秒数とマス目の和の偶奇を調べる
if ans==True:        
    for k in range(n):
        if li[k][0]%2==(li[k][1]+li[k][2])%2:
            continue
        ans=False
        print('No')
        break
        
if ans==True:
    print('Yes')
from collections import deque, defaultdict
from heapq import heappop, heappush

N, M = map(int, input().split())
edge = defaultdict(list)
for i in range(M):
    a, b = map(int, input().split())
    edge[(a, 0)].append((b, 1))
    edge[(a, 1)].append((b, 2))
    edge[(a, 2)].append((b, 0))

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

inf = 10 ** 10
dist = {}
for i in range(1, N+1):
    dist[(i, 0)] = inf
    dist[(i, 1)] = inf
    dist[(i, 2)] = inf
dist[(S, 0)] = 0

def BST(now, heap, dist):
    for node in edge[now]:
        if(dist[node] > dist[now] + 1):
            dist[node] = dist[now] + 1
            heappush(heap, node)
    if(heap):
        next_node = heappop(heap)
        BST(next_node, heap, dist)
    else:
        return

heap = []
BST((S, 0), [], dist)

if(dist[(T, 0)] == inf):
    print(-1)
else:
    print(dist[(T, 0)]//3)


### FIXED CODE ###

from collections import deque, defaultdict

N, M = map(int, input().split())
edge = defaultdict(list)
for i in range(M):
    a, b = map(int, input().split())
    edge[(a, 0)].append((b, 1))
    edge[(a, 1)].append((b, 2))
    edge[(a, 2)].append((b, 0))

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

inf = float('inf')
dist = {}
for i in range(1, N+1):
    dist[(i, 0)] = inf
    dist[(i, 1)] = inf
    dist[(i, 2)] = inf
dist[(S, 0)] = 0

dq = deque()
dq.append((S, 0))

while dq:
    v = dq.popleft()
    if v == (T, 0):
        break
    for u in edge[v]:
        if dist[u] < inf: continue
        dq.append(u)
        dist[u] = dist[v] + 1

if(dist[(T, 0)] == inf):
    print(-1)
else:
    print(dist[(T, 0)]//3)
n11, n12, n13 = map(int,input().split())
n21, n22, n23 = map(int,input().split())
n31, n32, n33 = map(int,input().split())
lines = [[n11,n12,n13],
         [n21,n22,n23],
         [n31,n32,n33],
         [n11,n21,n31],
         [n12,n22,n32],
         [n13,n23,n33],
         [n11,n22,n33],
         [n13,n22,n31]]
nums = {}
r = input()
for i in range(int(r)):
  nums[input()] = 0
flag = False
for l in lines:
  if l[0] in nums:
    if l[1] in nums:
      if l[2] in nums:
        flag = True
if flag:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

import math
s = input()
s = int(s)
s = s/2
s = math.ceil(s)
print(s)
s = input()
ans = []
for i in s:
    if i != "B":
        ans.append(i)
        continue
    if len(i) == 0:
        continue
    elif len(i) != 0:
        ans.pop()
print(*ans, sep="")


### FIXED CODE ###

s = input()
ans = []
for i in s:
    if i != "B":
        ans.append(i)
        continue
    if len(ans) == 0:
        continue
    elif len(ans) != 0:
        ans.pop()
print(*ans, sep="")
if __name__ == "__main__":

    date = input().replace("　", " ").split(" ")

    if date[0] <= date[1]:
        print(date[0])
    else:
        print(date[0]-1)


### FIXED CODE ###

if __name__ == "__main__":

    date = input().replace("　", " ").split(" ")

    if date[0] <= date[1]:
        print(date[0])
    else:
        print(int(date[0])-1)
print(6.28318530717958623200*int(input())

### FIXED CODE ###

print(6.28318530717958623200*int(input()))
import sys

x = []

for _ in range(3):
    x.extend(list(map(int,input().split())))
x.sort()
a = b = c = d = 0
for i in range(6):
    if x[i] == 1:
        a += 1
    elif x[i] == 2:
        b += 1
    elif x[i] == 3:
        c += 1
    else:
        d += 1
if a > 2 or a < 0:
    print("NO")
    sys.exit(1)
elif b > 2 or b < 0:
    print("NO")
    sys.exit(1)
elif c > 2 or c < 0:
    print("NO")
    sys.exit(1)
elif d > 2 or d < 0:
    print("NO")
    sys.exit(1)
print("YES")

### FIXED CODE ###

x = []
f  = 1
for _ in range(3):
    x.extend(list(map(int,input().split())))
cnt = [0]*4
for i in range(6):
    cnt[x[i]-1] += 1
for a in cnt:
    if a > 2:
        f = 0
if f:
    print("YES")
else:
    print("NO")
s=str(input())
y="".join([s[i] for i in range(0,len(s),w)])
print(y)

### FIXED CODE ###

s,w=str(input()),int(input())
y="".join([s[i] for i in range(0,len(s),w)])
print(y)
S=list(input())
K=int(input())
idx=[-1]*10
for i in '123456789':
    if i in S:
        idx[int(i)] = S.index(i)+1
if K < max(idx[2:]):
    print(1)
else:
    print(S[min(i for i in idx[2:]if i>0)-1])

### FIXED CODE ###

S=list(input())
K=int(input())
idx=[-1]*10
for i in '123456789':
    if i in S:
        idx[int(i)] = S.index(i)+1
if idx[2:]==[-1]*8 or K < max(idx[2:]):
    print(1)
else:
    print(S[min(i for i in idx[2:]if i>0)-1])
import random

S = input()
n = len(S)
i = 1+int(random.random()*(n-3))
print(S[i]+S[i+1]+S[i+2])

### FIXED CODE ###

import random


S = input()
n = len(S)
i = 0+int(random.random()*(n-3))
print(S[i]+S[i+1]+S[i+2])
import sys
sys.setrecursionlimit(500000)
n, W = map(int, input().split())
w, v = [], []

for i in range(n):
    temp1, temp2 = map(int, input().split())
    w.append(temp1)
    v.append(temp2)

#print(w, v)
#dp[i] = max(dp[i-1], dp[i]) + dp[i-2]

def solve(total, i):
    if i > n-1:
	return 0
    weight, val = w[i], v[i]
    if total + weight <= W:
        chose = val + solve(total + weight, i+1)
        unchose = solve(total, i+1)
        return max(chose, unchose)
    else:
        return 0

print(solve(0, 0))

### FIXED CODE ###

n, W = map(int, input().split())
w = [0]*(n+1)
v = [0]*(n+1)

#dp = [[None for i in range(W+1)] for j in range(n+1)]
dp = [[0 for i in range(W+1)] for j in range(n+1)]

for i in range(n):
    w[i], v[i] = map(int, input().split())

def knap(i, j):
    if dp[i][j] is not None:
        return dp[i][j]

    res = 0

    if i == n:
       	res = 0
    elif j < w[i]:
        res = knap(i+1, j)
    else:
        res = max(knap(i+1, j), knap(i+1, j-w[i]) + v[i])

    dp[i][j] = res
    return dp[i][j]

for i in reversed(range(n)):
    for j in range(W+1):
#        res = 0
        # if i == n-1:
        #     res = 0
        if j < w[i]:
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i])

#print(knap(0, W))
print(dp[0][W])
from heapq import heappop, heapify, heappush
import sys

input = sys.stdin.buffer.readline()

x, y, a, b, c = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
AB = A[:x] + (B[:y])

heapify(AB)
heapify(C)
ans = 0
for _ in range(len(C)):
    c = heappop(C)
    ab = heappop(AB)
    if ab > c:
        heappush(AB, ab)
        break
    heappush(AB, c)
ans = sum(AB)
print(ans)

### FIXED CODE ###

from heapq import heappop, heapify, heappush


x, y, a, b, c = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
D = [-i for i in C]
A.sort(reverse=True)
B.sort(reverse=True)
AB = A[:x] + (B[:y])

heapify(AB)
heapify(D)
ans = 0
for _ in range(c):
    d = -heappop(D)
    ab = heappop(AB)
    if ab > d:
        heappush(AB, ab)
        break
    heappush(AB, d)
ans = sum(AB)
print(ans)
n = input()
s = n.count(+) - n.count(-)
print(s)

### FIXED CODE ###

n = input()
s = n.count('+') - n.count('-')
print(s)
N, K = map(int, input())

if N % K:
    print(1)
else:
    print(0)

### FIXED CODE ###

N, K = map(int, input().split())

if N % K:
    print(1)
else:
    print(0)
n = input()
h = map(int, input().split())

cnt = 0
ret = 0
for i in range(n-1):
  if(h[i] >= h[i+1]):
    cnt = cnt+1
  else:
    ret = max(cnt,ret)
    cnt = 0
  if(i == n-2):
    ret = max(cnt,ret)
print(ret)
             

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))

cnt = 0
ret = 0
for i in range(n-1):
  if h[i] >= h[i+1]:
    cnt = cnt+1
  else:
    ret = max(cnt,ret)
    cnt = 0
  if i == n-2:
    ret = max(cnt,ret)
print(ret)
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

X, Y, A, B, C = LI()
p = LI()
q = LI()
r = LI()

p.sort(reverse= 1)
q.sort(reverse= 1)
r.sort(reverse= 1)

def solve():
    ans = 0
    p_selected = p[:X]
    q_selected = q[:Y]
    p_selected.sort()
    q_selected.sort()
    p_cnt = 0
    q_cnt = 0
    r_selected = r[:min((X + Y), len(r))]
    # print(p_selected, q_selected)

    ans += sum(p_selected) + sum(q_selected)
    for r_i in r_selected:
        if p_selected[p_cnt] > q_selected[q_cnt] and q_cnt < Y:
            if q_selected[q_cnt] < r_i:
                ans += r_i - q_selected[q_cnt]
                q_cnt += 1
            else:
                return ans
        elif p_cnt < X:
            if p_selected[p_cnt] < r_i:
                ans += r_i - p_selected[p_cnt]
                p_cnt += 1
            else:
                return ans
                
    return ans

ans = solve()

print(ans)

### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

X, Y, A, B, C = LI()
p = LI()
q = LI()
r = LI()

p.sort(reverse= 1)
q.sort(reverse= 1)
r.sort(reverse= 1)

def solve():
    ans = 0
    p_selected = p[:X]
    q_selected = q[:Y]
    p_selected.sort()
    q_selected.sort()
    p_cnt = 0
    q_cnt = 0
    r_selected = r[:min((X + Y), len(r))]
    # print(p_selected, q_selected)

    ans += sum(p_selected) + sum(q_selected)
    for r_i in r_selected:
    
        if q_cnt < Y and p_cnt < X:
            if p_selected[p_cnt] >= q_selected[q_cnt]:
                if q_selected[q_cnt] < r_i:
                    ans += r_i - q_selected[q_cnt]
                    q_cnt += 1
                else:
                    return ans
            elif p_selected[p_cnt] < q_selected[q_cnt]:
                if p_selected[p_cnt] < r_i:
                    ans += r_i - p_selected[p_cnt]
                    p_cnt += 1
                else:
                    return ans
        elif q_cnt < Y and p_cnt >= X:
            if q_selected[q_cnt] < r_i:
                ans += r_i - q_selected[q_cnt]
                q_cnt += 1
            else:
                return ans
        elif p_cnt < X and q_cnt >= Y:
            if p_selected[p_cnt] < r_i:
                ans += r_i - p_selected[p_cnt]
                p_cnt += 1
            else:
                return ans

    return ans

ans = solve()

print(ans)
a,b = map(int,raw_input().split())
if a>b:
	print 'a' + '>' + 'b'
elif a<b:
	print 'a' + '<' + 'b'
elif a==b:
	print 'a' + '==' + b'

### FIXED CODE ###

foo,bar = map(int,raw_input().split())
if foo > bar: print 'a > b'
elif foo < bar: print 'a < b'
elif foo == bar: print 'a == b'
n=int(input())
if n<6:print(int(n>2));quit()
M=10**9+7
ln,hn,dp=n-6,n-5,2
s=n-4
n,d=n-5,1
while n:
  for i in range(3):n=(n*ln)%M;ln-=1
  for i in range(2):n=(n*pow(hn,-1,M))%M;hn-=1
  d=(d*pow(dp,-1,M))%M;dp+=1
  s=(s+n*d)%M
print(s)

### FIXED CODE ###

n=int(input())
if n<7:print(n//3);quit()
M=10**9+7
ln,hn,dp=n-6,n-5,2
s=n-4
n,d=n-5,1
while n:
  for i in range(3):n=(n*ln)%M;ln-=1
  for i in range(2):n=(n*pow(hn,-1,M))%M;hn-=1
  d=(d*pow(dp,-1,M))%M;dp+=1
  s=(s+n*d)%M
print(s)
N = int(input())
A = int(input())

N = N % 500

if N > A:
  print(No)
else:
  print(Yes)

### FIXED CODE ###

N = int(input())
A = int(input())

N = N % 500

if N > A:
  print("No")
else:
  print("Yes")
a=int(input())
a=a[-1]
if a=3:
  print('bon')
elif a=2 or a=4 or a=5 or a=7 or a=9:
  print('hon')
else:
  print('pon')

### FIXED CODE ###

a=int(input())
b = a % 10
if b==3:
  print("bon")
elif b==2 or b==4 or b==5 or b==7 or b==9:
  print("hon")
else:
  print("pon")
import math

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

A=B=C=D=E=11

if a%10!=0:
  A=a%10
if b%10!=0:
  B=b%10
if c%10!=0:
  C=c%10
if d%10!=0:
  D=d%10
if e%10!=0:
  E=e%10

k=min(A,B,C,D,E)
if A=B=C=D=E=0:
  k=10
sum=(math.ceil(a/10)*10+math.ceil(b/10)*10+math.ceil(c/10)*10+math.ceil(d/10)*10+math.ceil(e/10)*10)

print(sum-10+k)

### FIXED CODE ###

import math

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

k=min((a-1)%10,(b-1)%10,(c-1)%10,(d-1)%10,(e-1)%10)+1

sum=(math.ceil(a/10)*10+math.ceil(b/10)*10+math.ceil(c/10)*10+math.ceil(d/10)*10+math.ceil(e/10)*10)

print(sum-10+k)
H, W, M = list(map(int, input().split()))
hrz = [0]*H
vrt = [0]*W
targets = set()
target_x = set()
target_y = set()
for _ in range(M):
    h, w = list(map(lambda x: int(x) - 1, input().split()))
    targets.add((h, w))
    hrz[h] += 1
    vrt[w] += 1
    target_x.add(w)
    target_y.add(h)

hrz_max = max(hrz)
vrt_max = max(vrt)
for h in [i for i in range(H) if hrz[i] == hrz_max]:
    for w in [i for i in range(H) if vrt[i] == vrt_max]:
        if not (h, w) in targets:
            print(hrz_max+vrt_max)
            exit()
print(hrz_max+vrt_max-1)


### FIXED CODE ###

H, W, M = list(map(int, input().split()))

targets = set()
row = [0]*H
col = [0]*W

for _ in range(M):
    h, w = list(map(lambda x: int(x) - 1, input().split()))
    row[h] += 1
    col[w] += 1
    targets.add((h, w))

r_max = max(row)
c_max = max(col)
ans = 0

maxed_h = set([h for h in range(H) if row[h] == r_max])
maxed_w = set([w for w in range(W) if col[w] == c_max])
bomb_option_sites_n = len(maxed_h)*len(maxed_w)
targets_on_bomb_option = 0
for th, tw in targets:
    if th in maxed_h and tw in maxed_w:
        targets_on_bomb_option += 1

if bomb_option_sites_n == targets_on_bomb_option:
    print(r_max + c_max - 1)
else:
    print(r_max + c_max)
alpha="abcdefghijklmnopqrstuvwxyz"
s=input()
s1=set(s)
s2=sorted(list(s1))
if len(alpha)>len(s2):
    a=list(alpha)
    for i in range(s2):
        a.remove(i)
    print(a[0])
    exit()
for i in range(len(alpha)):
    if s2[i]!=alpha[i]:
        print(alpha[i])
        exit()
print("None")

### FIXED CODE ###

S=input()
alpha="abcdefghijklmnopqrstuvwxyz"
l=[]
for s in alpha:
    if s not in S:
        l.append(s)
if len(l)==0:
    print("None")
    exit()
l.sort()
print(l[0])
#import
#import math
import numpy as np
#= int(input())
#= input()
N, W = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]

weight = [0] * N
value = [0] * N

for i in range(N):
    w, v = map(int, input().split())
    weight[i] = w
    value[i] = v



dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, W + 1):

        if x[i - 1][0] <= j:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight[i - 1]] + value[i - 1])
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[-1][W])


### FIXED CODE ###

#import
#import math
#import numpy as np
#= int(input())
#= input()
N, W = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]

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

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, W + 1):
        dp[i][j] = dp[i - 1][j]
        if i != 0 and x[i - 1][0] <= j:
            dp[i][j] = max(dp[i][j], dp[i-1][j-x[i-1][0]] + x[i-1][1])

print(dp[-1][W])
x = int(input())
n = [i**5 for i in range(63)]

a = 0
b = 0
for i in range(len(n)-1):
    now = abs(n[i]-x)
    next = abs(n[i+1]-x)
    if (now<next) or (i+1 == len(n)-1):
        a = i
        break

sign = 1 - 2*(n[a] < x)
pos = 0
while True:
    if (n[a] - n[pos]*sign) == x: 
        b = pos
        break
    pos += 1
print(a,b*sign)
        


### FIXED CODE ###

x = int(input())
n = [i**5 for i in range(119+1)]

a = 0
b = 0
res = False
i = 0
while not res:
    sign = 1 - 2*(n[i] < x)
    for j in range(i+1):
        if (n[i] - n[j] * sign) == x:
            print(i,j*sign)
            res = True
    i += 1
#ゴーレム判定函数
#pos=位置
#s=文字列
def survive(pos,s,spell,move,N):
    for i in range(0,len(spell)):
        if(s[pos]==spell[i]):
            pos+=move[i]
        #ゴーレムが消えたか判定
        if(pos<0 or pos>N):
            return False
    return True
    
N,Q=map(int,input().split())
s=str(input())
tmp1=""
tmp2=""
tmp=0
#AとかBとかそういう奴らがどのくらい動くのかをカウント
spell=[]
move=[]
for time in range(0,Q):
    tmp1,tmp2=map(str,input().split())
    spell.append(tmp1)
    if(tmp2=="L"):
        move.append(-1)
    elif(tmp2=="R"):
        move.append(1)
left=-1
right=-1
#上と下から探す
for i in range(0,N):
    if(survive(i,s,spell,move,N)):
        left=i
        break
for j in range(0,N):
    if(survive(N-1-j,s,spell,move,N)):
        right=N-1-j
        break
ans=0
if(left<0 and right<0):
    ans=0
else:
    ans=right-left+1
print(ans)

### FIXED CODE ###

#ゴーレム判定関数
#pos=位置
#s=文字列
def survive(pos,s,spell,move,N):
    for i in range(0,len(spell)):
        if(s[pos]==spell[i]):
            pos+=move[i]
        #ゴーレムが消えたか判定
        if(pos<0):
            return -1
        elif(pos>N-1):
            return 1
    return 0

N,Q=map(int,input().split())
s=str(input())
tmp1=""
tmp2=""
tmp=0
#AとかBとかそういう奴らがどのくらい動くのかをカウント
spell=[]
move=[]
for time in range(0,Q):
    tmp1,tmp2=map(str,input().split())
    spell.append(tmp1)
    if(tmp2=="L"):
        move.append(-1)
    elif(tmp2=="R"):
        move.append(1)
left_result=-1
right_result=N
#右にoutしていくやつのうちもっとも左のやつを探す
left=0
right=N-1
mid=0
judge=False
#何も右から出ていかないパターン
if(survive(N-1,s,spell,move,N)!=1):
    right_result=N
#全て右から出ていくパターン
elif(survive(0,s,spell,move,N)==1):
    right_result=0
else:
    while ((right+left)//2)!=mid:
        mid=(right+left)//2
        judge=survive(mid,s,spell,move,N)
        if(judge==1):
            right=mid
        else:
            left=mid
    right_result=right

#左にoutしていくやつのうちもっとも右のやつを探す
left=0
right=N-1
mid=0
judge=False
#何も左から出ていかないパターン
if(survive(0,s,spell,move,N)!=-1):
    left_result=-1
#全て左から出ていくパターン
elif(survive(N-1,s,spell,move,N)==-1):
    left_result=N-1
else:
    while ((right+left)//2)!=mid:
        mid=(right+left)//2
        judge=survive(mid,s,spell,move,N)
        if(judge==-1):
            left=mid
        else:
            right=mid
    left_result=left

ans=right_result-left_result-1
print(ans)
n=int(input())
hoge=list(map(int,input().split()))

color=[0]*9
for i in range(n):
  color[hoge[i]//400]+=1

ans=0
for i in color[:8]:
  if(i!=0):
    ans+=1
    
print(ans,ans+color[8])

### FIXED CODE ###

n=int(input())
hoge=list(map(int,input().split()))

color=[0]*9
for i in range(n):
  if(hoge[i]<3200):
    color[hoge[i]//400]+=1
  else:
    color[8]+=1

ans=0
for i in color[:8]:
  if(i!=0):
    ans+=1

if(color[8]==n):
  print(1,n)
else:
  print(ans,ans+color[8])
N,M = map(int, input().split())

A = list(map(int, input().split()))
S = sum(A)
x = S/(4*m)

count = 0

for i in A:
    if i >= x:
        count += 1

if count>=M:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

A = list(map(int, input().split()))
S = sum(A)
x = S/(4*M)

count = 0

for i in A:
    if i >= x:
        count += 1

if count>=M:
    print("Yes")
else:
    print("No")