Maxim wants to buy some games at the local game shop. There are $n$ games in the shop, the $i$-th game costs $c_i$.

Maxim has a wallet which can be represented as an array of integers. His wallet contains $m$ bills, the $j$-th bill has value $a_j$.

Games in the shop are ordered from left to right, Maxim tries to buy every game in that order.

When Maxim stands at the position $i$ in the shop, he takes the first bill from his wallet (if his wallet is empty then he proceeds to the next position immediately) and tries to buy the $i$-th game using this bill. After Maxim tried to buy the $n$-th game, he leaves the shop.

Maxim buys the $i$-th game if and only if the value of the first bill (which he takes) from his wallet is greater or equal to the cost of the $i$-th game. If he successfully buys the $i$-th game, the first bill from his wallet disappears and the next bill becomes first. Otherwise Maxim leaves the first bill in his wallet (this bill still remains the first one) and proceeds to the next game.

For example, for array $c = [2, 4, 5, 2, 4]$ and array $a = [5, 3, 4, 6]$ the following process takes place: Maxim buys the first game using the first bill (its value is $5$), the bill disappears, after that the second bill (with value $3$) becomes the first one in Maxim's wallet, then Maxim doesn't buy the second game because $c_2 > a_2$, the same with the third game, then he buys the fourth game using the bill of value $a_2$ (the third bill becomes the first one in Maxim's wallet) and buys the fifth game using the bill of value $a_3$.

Your task is to get the number of games Maxim will buy.


-----Input-----

The first line of the input contains two integers $n$ and $m$ ($1 \le n, m \le 1000$) — the number of games and the number of bills in Maxim's wallet.

The second line of the input contains $n$ integers $c_1, c_2, \dots, c_n$ ($1 \le c_i \le 1000$), where $c_i$ is the cost of the $i$-th game.

The third line of the input contains $m$ integers $a_1, a_2, \dots, a_m$ ($1 \le a_j \le 1000$), where $a_j$ is the value of the $j$-th bill from the Maxim's wallet.


-----Output-----

Print a single integer — the number of games Maxim will buy.


-----Examples-----
Input
5 4
2 4 5 2 4
5 3 4 6

Output
3

Input
5 2
20 40 50 20 40
19 20

Output
0

Input
6 4
4 8 15 16 23 42
1000 1000 1000 1000

Output
4



-----Note-----

The first example is described in the problem statement.

In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.

In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter until he runs out of bills in his wallet.

Difficulty: EASY
Tags: Implementation
Expected Time Complexity: O(N)

Starter code:

Solutions:
(n, m) = input().split()
n = int(n)
m = int(m)
c = list(map(int, input().split()))
a = list(map(int, input().split()))
b = 0
i = 0
j = 0
while n != 0:
	if m > 0:
		if c[i] <= a[j]:
			b = b + 1
			i = i + 1
			j = j + 1
			n = n - 1
			m = m - 1
		else:
			i = i + 1
			n = n - 1
	else:
		break
print(b)


temp = input().split()
c = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
count = 0
i = 0
while i < len(c) and len(a) > 0:
	if a[0] < c[i]:
		i += 1
	else:
		count += 1
		a = a[1:]
		c = c[i + 1:]
		i = 0
print(count)


lt = list(map(int, input().split(' ')))
n = lt[0]
m = lt[1]
c = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
k = 0
for i in range(n):
	if k == m:
		break
	elif c[i] <= a[0] and k < m:
		k += 1
		del a[0]
	else:
		continue
print(k)


numList = list(map(int, input().split()))
costlist = list(map(int, input().split()))
billlist = list(map(int, input().split()))
m = numList[0]
n = numList[1]
sum = 0
j = 0
for i in range(m):
	if billlist[j] >= costlist[i]:
		sum += 1
		j += 1
	if j == n:
		break
print(sum)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
k = list(map(int, input().split()))
(i, j) = (0, 0)
count = 0
while i < len(l) and j < len(k):
	if l[i] <= k[j]:
		count += 1
		j += 1
		i += 1
	else:
		i += 1
print(count)


(n, n1) = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
a1 = list(map(int, input().split(' ')))
c = 0
j = 0
for i in a:
	if j < n1 and a1[j] >= i:
		c += 1
		j += 1
print(c)


i = input().split()
a = int(i[0])
b = int(i[1])
cost = list(map(int, input().split()))
game = list(map(int, input().split()))
k = 0
count = 0
j = 0
while k < a and j < b:
	if cost[k] <= game[j]:
		count = count + 1
		j = j + 1
	k = k + 1
print(count)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
b = 0
for i in range(n):
	if c[i] <= a[0]:
		b += 1
		a.remove(a[0])
		if len(a) == 0:
			break
print(b)


zzzzz = input()
games = list(map(int, input().split()))
cash = list(map(int, input().split()))
need = 0
g_c = 0
c_c = 0
while g_c < len(games) and len(cash) > 0:
	if cash[c_c] >= games[g_c]:
		cash.remove(cash[0])
		g_c += 1
		need += 1
	else:
		g_c += 1
print(need)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
i = k = j = 0
while j < n and i < m:
	if a[i] >= c[j]:
		k += 1
		i += 1
		j += 1
	else:
		j += 1
print(k)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
q = 0
for i in range(len(a)):
	if q != len(b) and a[i] <= b[q]:
		q = q + 1
print(q)


(n, m) = input().split()
(n, m) = (int(n), int(m))
c = input().split()
a = input().split()
ai = 0
count = 0
for i in range(0, n):
	if int(a[ai]) >= int(c[i]):
		count = count + 1
		ai = ai + 1
	if ai == m:
		break
print(count)


(n, m) = [int(x) for x in input().split(' ')]
c = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
ci = 0
ai = 0
gc = 0
while ci < n and ai < m:
	if c[ci] <= a[ai]:
		gc = gc + 1
		ci = ci + 1
		ai = ai + 1
	else:
		ci = ci + 1
print(gc)


input()
a = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))
count = 0
i = 0
while i < len(c):
	e = 0
	while e < len(a):
		if c[i] >= a[e]:
			count += 1
			a = a[e:]
			a.pop(0)
			break
		else:
			a.pop(0)
	i += 1
print(count)


(c, a) = (int(i) for i in input().split())
C = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
k = 0
for i in range(c):
	if A != [] and C[i] <= A[0]:
		k += 1
		A.pop(0)
print(k)


def gs(l1, l2):
	c = 0
	d = 0
	for i in range(len(l1)):
		if c < len(l2) and l1[i] <= l2[c]:
			d = d + 1
			c = c + 1
	print(d)
(n, m) = map(int, input().split(' '))
l1 = list(map(int, input().split(' ')))
l2 = list(map(int, input().split(' ')))
gs(l1, l2)


(n, m) = list(map(int, input().split()))
costs = list(map(int, input().split()))
money = list(map(int, input().split()))
counter = 0
for i in range(n):
	if len(money) != 0 and costs[i] <= money[0]:
		counter += 1
		money.pop(0)
print(counter)


(n, m) = map(int, input().split())
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
i = 0
sum = 0
for j in range(len(a)):
	for k in range(i, n):
		if c[i] <= a[j]:
			sum += 1
			i += 1
			break
		i += 1
print(sum)


def mi():
	return map(int, input().split())
(n1, n2) = mi()
c = list(mi())
a = list(mi())
i = 0
j = 0
cnt = 0
while i < n1 and j < n2:
	cur = c[i]
	if cur <= a[j]:
		j += 1
		cnt += 1
	i += 1
print(cnt)


p = lambda : list(map(int, input().split()))
p()
(a, b) = (p(), p())
c = 0
for i in a:
	c += c < len(b) and i <= b[c]
print(c)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
j = 0
for i in c:
	if j >= len(a):
		break
	if i <= a[j]:
		ans += 1
		j += 1
print(ans)


(n, m) = map(int, input().split())
li = list(map(int, input().split()))
li2 = list(map(int, input().split()))
c = 0
for i in li:
	c += c < len(li2) and li2[c] >= i
print(c)


(n, m) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
j = 0
c = d = 0
for i in range(len(l1)):
	if l2[j] >= l1[i]:
		j += 1
		c += 1
	if j == m:
		break
print(c)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
j = 0
count = 0
for i in range(n):
	if j >= m:
		break
	if a[j] >= c[i]:
		count += 1
		j += 1
print(count)


n = list(map(int, input().split()))
m = n[1]
n = n[0]
c = list(map(int, input().split()))
a = list(map(int, input().split()))
i = 0
j = 0
count = 0
while i < len(c):
	if j < len(a) and a[j] >= c[i]:
		count += 1
		j += 1
	i += 1
print(count)


l = input().split()
n = int(l[0])
m = int(l[1])
c = input().split()
a = input().split()
count = 0
for i in range(n):
	if len(a) != 0:
		if int(a[0]) >= int(c[i]):
			count = count + 1
			a.remove(a[0])
	else:
		break
print(count)


(n, m) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
l2 = list(map(int, input().split(' ')))
j = 0
c = 0
i = 0
while i < n and j < m:
	if l2[j] >= l[i]:
		j += 1
		i += 1
		c += 1
	else:
		i += 1
print(c)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pt = 0
cnt = 0
for i in a:
	if pt == m or b[pt] < i:
		continue
	else:
		pt += 1
		cnt += 1
print(cnt)


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

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

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	(n, m) = LI()
	a = LI()
	b = LI()
	b.reverse()
	ans = 0
	for x in a:
		if len(b) <= 0:
			return ans
		if x <= b[-1]:
			b.pop()
			ans += 1
	return ans
print(main())


(n, m) = input().strip().split()
g = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
c = 0
while len(g) > 0 and len(b) > 0:
	if b[0] >= g[0]:
		c += 1
		del b[0]
	del g[0]
print(c)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r = 0
for i in a:
	r += r < len(b) and b[r] >= i
print(r)


(n, m) = map(int, input().split())
a = [*map(int, input().split())]
b = [*map(int, input().split())]
res = 0
for i in a:
	res += res < len(b) and b[res] >= i
print(res)


def ma():
	return list(map(int, input().split()))
(n, m) = ma()
(i, j) = (0, 0)
A = list(ma())
B = list(ma())
ans = 0
while i < len(A) and j < len(B):
	if A[i] <= B[j]:
		j += 1
		i += 1
		ans += 1
	else:
		i += 1
print(ans)


(n, m) = input().split()
n = int(n)
m = int(m)
tmp = input().split()
cost = [int(tmp[i]) for i in range(n)]
tmp = input().split()
bills = [int(tmp[i]) for i in range(m)]
ans = 0
j = 0
for i in cost:
	if j == m:
		break
	if i <= bills[j]:
		ans += 1
		j += 1
print(ans)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
i = 0
for cc in c:
	if i != m and a[i] >= cc:
		ans += 1
		i += 1
print(ans)


(n, m) = map(int, input().split())
games = list(map(int, input().split()))
wal = list(map(int, input().split()))
if m == 0:
	print(0)
	exit()
pos = 0
cnt = 0
for g in games:
	if pos == m:
		break
	if wal[pos] >= g:
		pos += 1
		cnt += 1
print(cnt)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
costIndex = 0
billIndex = 0
while n > 0:
	n -= 1
	if billIndex == m:
		continue
	if c[costIndex] <= a[billIndex]:
		billIndex += 1
		ans += 1
	costIndex += 1
print(ans)


a = input()
j = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]
jj = 0
dd = 0
jc = 0
while jj < len(j) and dd < len(d):
	if d[dd] >= j[jj]:
		dd += 1
		jj += 1
		jc += 1
	else:
		jj += 1
print(jc)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
a.reverse()
ans = 0
for i in c:
	if i <= a[-1]:
		ans += 1
		a.pop()
	if ans == m:
		break
print(ans)


(n, m) = map(int, input().split())
a = [int(elem) for elem in input().split()]
b = [int(elem) for elem in input().split()]
ans = 0
for i in range(n):
	if len(b) > 0 and a[i] <= b[0]:
		b = b[1:]
		ans = ans + 1
print(ans)


(n, m) = map(int, input().split())
ci = list(map(int, input().split()))
ai = list(map(int, input().split()))
toys = 0
j = 0
for i in range(n):
	if j > m - 1:
		break
	if ci[i] <= ai[j]:
		toys += 1
		j += 1
print(toys)


(n, m) = map(int, input().strip().split(' '))
gamecost = list(map(int, input().strip().split(' ')))
bills = list(map(int, input().strip().split(' ')))
i = 0
j = 0
while i < n and j < m:
	if gamecost[i] <= bills[j]:
		j += 1
	i += 1
print(j)


(n, m) = map(int, input().split())
G = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
(iG, iB) = (0, 0)
while iG < n and iB < m:
	if B[iB] >= G[iG]:
		ans += 1
		iB += 1
	iG += 1
print(ans)


(n, m) = list(map(int, input().strip().split()))
ci = list(map(int, input().strip().split()))
ai = list(map(int, input().strip().split()))
i = 0
j = 0
count = 0
while i < n and j < m:
	if ci[i] <= ai[j]:
		i = i + 1
		j = j + 1
		count = count + 1
	else:
		i = i + 1
print(count)


string = input().split(' ')
n = int(string[0])
m = int(string[1])
cost = input().split(' ')
wallet = input().split(' ')
currentGame = 0
count = 0
while len(wallet) > 0 and currentGame <= n - 1:
	if int(wallet[0]) >= int(cost[currentGame]):
		count += 1
		wallet.pop(0)
	currentGame += 1
print(count)


(n, m) = map(int, input().split())
c = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
g = 0
for v in c:
	if g < m and v <= a[g]:
		g += 1
print(g)


done = False

def solve(c, a):
	ans = 0
	tempJ = -1
	for i in a:
		done = False
		j = tempJ + 1
		while j < len(c):
			if i >= c[j]:
				ans += 1
				done = True
				tempJ = j
				break
			j += 1
		if done == False:
			break
	return ans

def main():
	(n, m) = map(int, input().split())
	c = list(map(int, input().split()))
	a = list(map(int, input().split()))
	print(solve(c, a))
main()


(n, m) = map(int, input().split())
cog = list(map(int, input().split()))
bill = list(map(int, input().split()))
buy = 0
for i in range(n):
	flag = 0
	if len(bill) == 0 or len(cog) == 0:
		break
	for j in range(len(cog)):
		if bill[0] >= cog[0]:
			buy += 1
			flag = 1
			bill.pop(0)
			cog.pop(j)
			break
		if flag == 0:
			cog.pop(j)
			break
print(buy)


(m, n) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
i = 0
c = 0
j = 0
while i < m and j < n:
	if l[i] > l2[j]:
		i += 1
	else:
		i += 1
		j += 1
		c += 1
print(c)


l = [int(i) for i in input().split()]
n = l[0]
m = l[1]
c = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
k = 0
j = 0
for i in range(n):
	if j < m:
		if a[j] >= c[i]:
			k += 1
			j += 1
	elif j == m:
		break
print(k)


i = lambda : map(int, input().split())
(n, m) = i()
(a, b) = (i(), [*i()])
k = 0
for x in a:
	k = k + (x <= b[k])
	if k == m:
		break
print(k)


(n, m) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
cnt = 0
(i, j) = (0, 0)
while True:
	if i == n or j == m:
		break
	elif a[i] <= b[j]:
		cnt += 1
		i += 1
		j += 1
	else:
		i += 1
print(cnt)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(i, j) = (0, 0)
while i < n and j < m:
	if a[i] <= b[j]:
		j += 1
	i += 1
print(j)


class CodeforcesTask1009ASolution:

	def __init__(self):
		self.result = ''
		self.n_m = []
		self.prices = []
		self.wallet = []

	def read_input(self):
		self.n_m = [int(x) for x in input().split(' ')]
		self.prices = [int(x) for x in input().split(' ')]
		self.wallet = [int(x) for x in input().split(' ')]

	def process_task(self):
		bought = 0
		self.prices = self.prices[::-1]
		self.wallet = self.wallet[::-1]
		bill = self.wallet.pop(-1)
		while self.prices and bill:
			buyin = self.prices.pop(-1)
			if bill >= buyin:
				bill = None
				bought += 1
			if not bill:
				if self.wallet:
					bill = self.wallet.pop(-1)
				else:
					break
		self.result = str(bought)

	def get_result(self):
		return self.result
Solution = CodeforcesTask1009ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(n, m) = map(int, input().split())
(C, A) = (list(map(int, input().split())), list(map(int, input().split())))
i = j = games = 0
while i < n and j < m:
	if C[i] <= A[j]:
		(j, games) = (j + 1, games + 1)
	i += 1
print(games)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m) = LI()
	a = LI()
	b = LI()
	bi = 0
	for c in a:
		if b[bi] >= c:
			bi += 1
			if bi == len(b):
				break
	return bi
print(main())


(n, m) = [int(x) for x in input().strip().split()]
c = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
i = 0
j = 0
count = 0
while i < n and j < m:
	if c[i] <= a[j]:
		count += 1
		i += 1
		j += 1
	else:
		i += 1
print(count)


def process(bigger, lower):
	answer = 0
	(i, j) = (0, 0)
	while i < len(bigger) and j < len(lower):
		if bigger[i] <= lower[j]:
			answer += 1
			i += 1
			j += 1
		else:
			i += 1
	return answer

def int_input(array, number):
	for i in range(number):
		array.append(int(input()))

def main():
	(n, m) = map(int, input().split())
	price = list(map(int, input().split()))
	money = list(map(int, input().split()))
	answer = process(price, money)
	print(answer)
main()


count = input()
games = input().split()
coins = input().split()
counter = 0
i = 0
j = 0
while i < len(coins) and j < len(games):
	if int(coins[i]) >= int(games[j]):
		i += 1
		j += 1
		counter += 1
	else:
		j += 1
print(counter)


__author__ = 'Dilshod'
(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = 0
try:
	for i in range(n):
		if c[i] <= a[0]:
			cnt += 1
			del a[0]
except:
	pass
print(cnt)


cnt = i = 0
(n, m) = map(int, input().split())
(c, a) = ([int(q) for q in input().split()], [int(q) for q in input().split()])
while len(a) * len(c) != 0:
	if a[i] >= c[i]:
		cnt += 1
		a.pop(i)
	c.pop(i)
print(cnt)


input()
cs = map(int, input().split())
vs = list(map(int, input().split()))
vi = 0
res = 0
for c in cs:
	if c <= vs[vi]:
		res += 1
		vi += 1
		if vi >= len(vs):
			break
print(res)


(n, m) = map(int, input().split())
c = tuple(map(int, input().split()))
a = tuple(map(int, input().split()))
i = j = 0
while i < n and j < m:
	if a[j] >= c[i]:
		j += 1
	i += 1
print(j)


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
i = 0
j = 0
ans = 0
while i < n and j < m:
	if a[i] <= b[j]:
		i += 1
		j += 1
		ans += 1
	else:
		i += 1
print(j)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
(n, m) = map(int, sys.stdin.readline().split(' '))
c = list(map(int, sys.stdin.readline().split(' ')))
a = list(map(int, sys.stdin.readline().split(' ')))
ans = 0
for i in range(n):
	if len(a) and c[i] <= a[0]:
		del a[0]
		ans += 1
print(ans)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


(n, m) = map(int, input().split())
cost = list(map(int, input().split()))
bill = list(map(int, input().split()))
j = 0
c = 0
i = 0
while i < m and j < n:
	if bill[i] >= cost[j]:
		c += 1
		i += 1
	j += 1
print(c)


input()
c = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
res = 0
i = 0
j = 0
while i < len(a) and j < len(c):
	if c[j] <= a[i]:
		res += 1
		i += 1
	j += 1
print(res)


(n, m) = map(int, input().split())
games = list(map(int, input().split()))
wallet = list(map(int, input().split()))
count = 0
for i in games:
	if wallet == []:
		break
	elif wallet[0] >= i:
		count += 1
		wallet.pop(0)
print(count)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = 0
while a != [] and c != []:
	if a[0] >= c[0]:
		cnt = cnt + 1
		a.remove(a[0])
		c.remove(c[0])
	else:
		c.remove(c[0])
print(cnt)


R = lambda : map(int, input().split())
(n, m) = R()
(c, a) = (R(), R())
r = 0
for x in a:
	r += next((1 for y in c if y <= x), 0)
print(r)


(n, m) = map(int, input().split())
n = int(n)
m = int(m)
g = input().split()
w = input().split()
c = 0
i = j = 0
for i in range(len(g)):
	try:
		if int(w[0]) >= int(g[i]):
			c += 1
			del w[0]
	except Exception as e:
		pass
print(c)


import atexit, io, sys
buffer = io.StringIO()
sys.stdout = buffer

@atexit.register
def write():
	sys.__stdout__.write(buffer.getvalue())
from sys import stdin

def main():
	_ = stdin.readline()
	costo_juegos = (int(n) for n in stdin.readline().split())
	billetera = [int(n) for n in stdin.readline().split()]
	cont = 0
	for juego in costo_juegos:
		if billetera[0] >= juego:
			billetera.pop(0)
			cont += 1
		if not billetera:
			break
	print('%d' % cont)
main()


a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
w = [int(x) for x in input().split(' ')]
bi = 0
wi = 0
count = 0
while wi < len(w) and bi < len(b):
	if w[wi] >= b[bi]:
		wi += 1
		count += 1
	bi += 1
print(count)


(n, m) = map(int, input().split())
(*games,) = map(int, input().split())
(*bills,) = map(int, input().split())
(i, j, counter) = (0, 0, 0)
while True:
	if games[i] <= bills[j]:
		counter += 1
		j += 1
	i += 1
	if i == n or j == m:
		break
print(counter)


(n, m) = list(map(int, input().split(' ')))
prices = list(map(int, input().split(' ')))
money = list(map(int, input().split(' ')))
res = 0
cur = 0
for price in prices:
	if money[cur] >= price:
		res += 1
		cur += 1
	if cur >= len(money):
		break
print(res)


(n, k) = list(map(int, input().split()))
c = list(map(int, input().split()))
m = list(map(int, input().split()))
result = 0
for cc in c:
	if len(m) == 0:
		break
	if m[0] >= cc:
		result += 1
		m = m[1:]
print(result)


nm = input()
c = list(map(lambda x: int(x), input().split()))
a = list(map(lambda x: int(x), input().split()))
res = 0
for game_cost in c:
	if len(a) == 0:
		break
	if game_cost <= a[0]:
		res += 1
		a.pop(0)
print(res)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
y = 0
for i in range(n):
	if m != 0:
		if b[0] >= a[i]:
			m -= 1
			y += 1
			b.remove(b[0])
print(y)


(n, m) = map(int, input().split())
games = list(map(int, input().split()))
bills = list(map(int, input().split()))
counter = 0
i = 0
j = 0
while len(bills) != 0 and len(games) != 0:
	while i <= len(games) and j <= len(bills):
		try:
			if bills[j] >= games[i]:
				counter += 1
				i += 1
				j += 1
			else:
				i += 1
		except:
			print(counter)
			bills[:] = []
			games[:] = []


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
d = list(map(int, input().split()))
ci = 0
di = 0
ans = 0
for i in range(n):
	if di == m:
		break
	if d[di] >= c[i]:
		di += 1
		ans += 1
print(ans)


from math import ceil
t = 1
for test in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 0
	index = 0
	for i in a:
		if index >= m:
			break
		if b[index] >= i:
			ans += 1
			index += 1
	print(ans)


(n, k) = map(int, input().split())
g = list(map(int, input().split()))
a = list(map(int, input().split()))
(i, j) = (0, 0)
num = 0
while i < len(g) and j < len(a):
	if g[i] <= a[j]:
		i += 1
		j += 1
		num += 1
	else:
		i += 1
print(num)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
h = list(map(int, input().split()))
c = 0
f = 0
for i in range(len(l)):
	if h[f] >= l[i]:
		c += 1
		f += 1
	if f == len(h):
		break
print(c)


xy = list(map(int, input().split()))
x = xy[0]
y = xy[1]
c = 0
a = list(map(int, input().split()))
b = list(map(int, input().split()))
i = 0
j = 0
while i < x and j < y:
	if a[i] <= b[j]:
		c += 1
		i += 1
		j += 1
	else:
		i += 1
print(c)


(count_games, count_bills) = map(int, input().split())
prices_of_games = [int(price) for price in input().split()]
prices_of_bills = [int(price) for price in input().split()]
count_buys = 0
bill_index = 0
for game_index in range(count_games):
	if bill_index == count_bills:
		continue
	if prices_of_games[game_index] <= prices_of_bills[bill_index]:
		count_buys += 1
		bill_index += 1
print(count_buys)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = j = 0
for i in range(n):
	if j == m:
		break
	if a[i] <= b[j]:
		ans += 1
		j += 1
print(ans)


(n, m) = list(map(int, input().split()))
listn = list(map(int, input().split()))
listm = list(map(int, input().split()))
bought = []
j = 0
for i in range(n):
	if j < m:
		if listm[j] >= listn[i]:
			bought.append(listn[i])
			j += 1
print(len(bought))


(nbGames, nbBills) = map(int, input('').split(' '))
games = input('').split(' ')
bills = input('').split(' ')
billToSpend = 0
gamesBought = 0
for loop in range(nbGames):
	if int(bills[billToSpend]) >= int(games[loop]) and billToSpend < nbBills - 1:
		billToSpend += 1
		gamesBought += 1
	elif int(bills[billToSpend]) >= int(games[loop]):
		gamesBought += 1
		bills[billToSpend] = -1
print(gamesBought)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l2.append(0)
count = 0
for i in range(n):
	if l[i] <= l2[0] and count < m:
		count += 1
		l2.pop(0)
print(count)


(n, m) = [int(x) for x in input().split()]
lst1 = [int(x) for x in input().split()]
lst2 = [int(x) for x in input().split()]
x = 0
y = 0
s = 0
while x != n and y != m:
	if lst1[x] <= lst2[y]:
		s += 1
		y += 1
		x += 1
	elif lst1[x] > lst2[y]:
		x += 1
print(s)


from sys import exit
(n, m) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
(i1, i2) = (0, 0)
q = 0
while i1 < n and i2 < m:
	if b[i2] >= s[i1]:
		i2 += 1
		q += 1
	i1 += 1
print(q)


def fair(a, b, n, m):
	(j, c) = (0, 0)
	for i in range(m):
		while j < n:
			if b[i] >= a[j]:
				c += 1
				j += 1
				break
			j += 1
	print(c)
ca = list(map(int, input().split()))
(n, m) = (ca[0], ca[1])
a = list(map(int, input().split()))
b = list(map(int, input().split()))
fair(a, b, n, m)


import bisect
(n, m) = input().strip().split(' ')
(n, m) = (int(n), int(m))
c = list(map(int, input().strip().split(' ')))
a = list(map(int, input().strip().split(' ')))
i = 0
j = 0
cnt = 0
while i < n and j < m:
	if a[j] >= c[i]:
		cnt += 1
		i += 1
		j += 1
	else:
		i += 1
print(cnt)


gameCount = list(map(int, input().split(' ')))
priceArr = list(map(int, input().split(' ')))
billArr = list(map(int, input().split(' ')))
front = 0
purchased = 0
for i in range(gameCount[0]):
	if front >= gameCount[1]:
		break
	if billArr[front] < priceArr[i]:
		continue
	else:
		purchased += 1
		front += 1
print(purchased)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
pre = 0
for x in a:
	if pre < m and x <= b[pre]:
		ans += 1
		pre += 1
print(ans)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in c:
	try:
		if i <= a[0]:
			a.pop(0)
	except:
		break
print(m - len(a))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
w = list(map(int, input().split()))
g = 0
while len(c) > 0:
	if w[0] >= c[0]:
		c.pop(0)
		w.pop(0)
		g += 1
	elif w[0] < c[0]:
		c.pop(0)
	if len(w) == 0:
		break
print(g)


(n, m) = [int(x) for x in input().split()]
c = list(map(int, input().split()))
a = list(map(int, input().split()))
m = 0
while c != [] and a != []:
	if a[0] >= c[0]:
		m += 1
		a.remove(a[0])
		c.remove(c[0])
	else:
		c.remove(c[0])
print(m)


(n, m) = map(int, input().split())
games = list(map(int, input().split()))
moneys = list(map(int, input().split()))
answer = 0
game_ind = 0
money_ind = 0
while game_ind < n and money_ind < m:
	if moneys[money_ind] >= games[game_ind]:
		answer += 1
		game_ind += 1
		money_ind += 1
	else:
		game_ind += 1
print(answer)


(n, m) = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
cnt = 0
for i in range(n):
	if len(A) == 0:
		break
	if A[0] >= C[i]:
		cnt += 1
		del A[0]
print(cnt)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
bought = 0
for game in c:
	if len(a) > 0 and a[0] >= game:
		bought += 1
		a.pop(0)
print(bought)


(n, m) = map(int, input().split())
c = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
count = 0
for i in range(0, n):
	if a[0] >= c[i]:
		del a[0]
		count += 1
	if len(a) == 0:
		break
print(count)


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
b.append(-1)
f = 0
ans = 0
for i in a:
	if b[f] >= i:
		f += 1
		ans += 1
print(ans)


def main():
	input()
	cc = list(map(int, input().split()))[::-1]
	aa = list(map(int, input().split()))[::-1]
	res = 0
	while aa and cc:
		(a, c) = (aa[-1], cc.pop())
		if a >= c:
			res += 1
			del aa[-1]
	print(res)
main()


(n, k) = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
m = [int(i) for i in input().split()]
j = 0
t = 0
for i in range(n):
	if p[i] <= m[j]:
		t += 1
		j += 1
	if j == k:
		break
print(t)


from collections import deque
(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
c = deque(c)
a = deque(a)
ans = 0
while a and c:
	if a[0] >= c[0]:
		a.popleft()
		c.popleft()
		ans += 1
	else:
		c.popleft()
print(ans)


(n, m) = map(int, input().split())
mat = list(map(int, input().split()))
sat = list(map(int, input().split()))
j = 0
i = 0
res = 0
while i < n:
	if mat[i] <= sat[j]:
		res += 1
		j += 1
		if j >= m:
			break
	i += 1
print(res)


import collections
from functools import cmp_to_key
import math
import sys

def getIntList():
	return list(map(int, input().split()))
import bisect
try:
	import numpy
	dprint = print
	dprint('debug mode')
except ModuleNotFoundError:

	def dprint(*args, **kwargs):
		pass

def makePair(z):
	return [(z[i], z[i + 1]) for i in range(0, len(z), 2)]

def memo(func):
	cache = {}

	def wrap(*args):
		if args not in cache:
			cache[args] = func(*args)
		return cache[args]
	return wrap

@memo
def comb(n, k):
	if k == 0:
		return 1
	if n == k:
		return 1
	return comb(n - 1, k - 1) + comb(n - 1, k)
(n, m) = getIntList()
zc = getIntList()
za = getIntList()
res = 0
i = 0
for c in zc:
	if za[i] >= c:
		res += 1
		i += 1
		if i >= m:
			break
print(res)


answer = 0
i2 = 0
(nbgames, nbbills) = map(int, input('').split(' '))
games = input('').split(' ')
wallet = input('').split(' ')
for i in range(max(nbgames, nbbills)):
	games.append(1001)
	wallet.append(0)
	if int(games[i2]) <= int(wallet[i2]):
		answer += 1
	else:
		del games[i2]
		i2 -= 1
	i2 += 1
print(answer)


(n, m) = [int(i) for i in input().split()]
cg = [int(i) for i in input().split()]
ab = [int(i) for i in input().split()]
j = 0
i = 0
count = 0
while i < n and j < m:
	if cg[i] <= ab[j]:
		count += 1
		i = i + 1
		j = j + 1
	else:
		i = i + 1
		if ab[j] == 0:
			j = j + 1
			i = i - 1
print(count)


nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])
c = input().split(' ')
a = input().split(' ')
i = 0
j = 0
for x in a:
	if j < len(c):
		for y in range(j, len(c)):
			if int(x) >= int(c[y]):
				j = y + 1
				i += 1
				break
			else:
				j = y + 1
print(i)


(n, m) = input().split(' ')
(n, m) = (int(n), int(m))
N = input().split(' ')
for i in range(n):
	N[i] = int(N[i])
M = input().split(' ')
for i in range(m):
	M[i] = int(M[i])
M.append(0)
k = 0
t = 0
for i in range(n):
	if M[k] >= N[i]:
		k += 1
		t += 1
print(t)


a = input().split()
n = int(a[0])
m = int(a[1])
an = input().split()
am = input().split()
x = 0
sum = 0
for i in range(n):
	if int(an[i]) <= int(am[x]):
		x += 1
		sum += 1
	if x >= m:
		break
print(sum)


(c, a) = input().split()
a = int(a)
c = int(c)
x = input().split(' ')
cl = [int(i) for i in x if i != ' ']
x = input().split(' ')
al = [int(i) for i in x if i != ' ']
count = 0
i = 0
j = 0
while i < len(al) and j < len(cl):
	if al[i] >= cl[j]:
		count += 1
		i += 1
		j += 1
	else:
		j += 1
print(count)


(res, _) = (0, input())
n = [int(x) for x in input().split()]
m = [int(x) for x in input().split()] + [0]
for row in n:
	res += row <= m[res]
print(res)


def solve(n, m, c, a):
	s = 0
	for i in c:
		if a and a[0] >= i:
			s += 1
			a.pop(0)
	return s

def main():
	(n, m) = list(map(int, input().split()))
	c = list(map(int, input().split()))
	a = list(map(int, input().split()))
	print(solve(n, m, c, a))
main()


(n, m) = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
(i, j) = (0, 0)
res = 0
while i < n and j < m:
	if a[j] >= c[i]:
		res += 1
		j += 1
	i += 1
print(res)


(n, m) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = c[::-1]
a = a[::-1]
counter = 0
while len(a) != 0 and len(c) != 0:
	if a[len(a) - 1] >= c[len(c) - 1]:
		a.pop()
		counter += 1
	c.pop()
print(counter)


def do():
	(n, k) = map(int, input().split())
	datn = list(map(int, input().split()))
	datm = list(map(int, input().split()))
	cur = 0
	res = 0
	for i in range(n):
		if datn[i] <= datm[cur]:
			res += 1
			cur += 1
		if cur >= k:
			break
	print(res)
do()

def resolve():
	from pprint import pprint
	q = int(input())
	for _ in range(q):
		s = input()
		n = int(input())
		(n, k) = map(int, input().split())
		dat = list(map(int, input().split()))
	dat = [1, 2, 3]
	print(' '.join(list(map(str, res))))
	pass
	import math
	math.ceil(1.2)
	math.floor(1.2)
	round(1.2, 3)


(n, m) = map(int, input().split())
c = map(int, input().split())
a = list(map(int, input().split()))
ind = 0
ans = 0
for elem in c:
	if ind < len(a) and a[ind] >= elem:
		ans += 1
		ind += 1
print(ans)


fixed = set(['0', '2'])

def buy(games, bills):
	count = 0
	inda = 0
	indb = 0
	while inda < len(games):
		if indb == len(bills):
			break
		if games[inda] <= bills[indb]:
			count += 1
			indb += 1
		inda += 1
	return count
input()
print(buy(list(map(int, input().split(' '))), list(map(int, input().split(' ')))))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
q = 0
for i in range(len(c)):
	if c[i] <= a[0]:
		a.pop(0)
		q += 1
	if len(a) < 1:
		break
print(q)


(n, m) = map(int, input().split())
game = list(map(int, input().split()))
cash = list(map(int, input().split()))
count = 0
check = False
j = 0
for i in range(m):
	if check:
		break
	while j < n:
		if j == n - 1:
			check = True
		if cash[i] >= game[j] and cash[i] != -1 and (game[j] != -1):
			count += 1
			cash[i] = -1
			game[j] = -1
			j += 1
			break
		j += 1
print(count)


(n, m) = map(int, input().split())
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
count = 0
for i in range(len(c)):
	if len(a) == 0:
		print(m)
		exit(0)
	if c[i] <= a[0]:
		count += 1
		a.remove(a[0])
print(count)


(n, m) = [int(a) for a in input().split()]
c = [int(b) for b in input().split()]
a = [int(c) for c in input().split()]
num1 = 0
num2 = 0
total = 0
while num1 < n and num2 < m:
	if c[num1] > a[num2]:
		num1 += 1
		continue
	num1 += 1
	num2 += 1
	total += 1
print(total)


(g, w) = map(int, input().split())
gf = list(map(int, input().split()))
wf = list(map(int, input().split()))
i = 0
t = 0
c = 0
while i != g and t != w:
	if wf[t] >= gf[i]:
		t = t + 1
		i = i + 1
		c = c + 1
	elif wf[t] < gf[i]:
		i = i + 1
print(c)


(n, m) = [int(x) for x in input().strip().split(' ')]
c = [int(x) for x in input().strip().split(' ')]
a = [int(x) for x in input().strip().split(' ')]
ans = 0
j = 0
for i in range(n):
	if j >= m:
		break
	if c[i] <= a[j]:
		j += 1
		ans += 1
print(ans)


(n, m) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
i = 0
j = 0
ans = 0
while i < m and j < n:
	if l2[i] >= l1[j]:
		i += 1
		j += 1
		ans += 1
	else:
		j += 1
print(ans)


inp = input().split(' ')
(n, m) = (int(inp[0]), int(inp[1]))
c = input().split(' ')
a = input().split(' ')
bill = 0
for i in range(n):
	if bill == len(a):
		break
	if int(a[bill]) >= int(c[i]):
		bill += 1
print(bill)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
arr1 = list(map(int, input().split()))
cnt = 0
for i in range(len(arr)):
	if cnt == len(arr1):
		break
	if arr1[cnt] >= arr[i]:
		cnt += 1
print(cnt)


str1 = input()
tp1 = str1.split()
n = int(tp1[0])
m = int(tp1[1])
str1 = input()
a = str1.split(' ')
str1 = input()
b = str1.split(' ')
j = 0
cnt = 0
for i in range(n):
	if j < m:
		if int(b[j]) >= int(a[i]):
			j = j + 1
			cnt = cnt + 1
print(cnt)


(n, m) = map(int, input().split())
s = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]
(i, t) = (0, 0)
while len(d) > i and len(s) > t:
	if d[i] >= s[t]:
		i += 1
		t += 1
	else:
		t += 1
print(i)


(a, b) = map(int, input().rstrip().split())
games = list(map(int, input().rstrip().split()))
wallet = list(map(int, input().rstrip().split()))
iwallet = 0
for i in range(a):
	if iwallet < b:
		if games[i] <= wallet[iwallet]:
			iwallet += 1
		else:
			continue
	else:
		break
print(iwallet)


TN = 1

def solution():
	(n, m) = map(int, input().split())
	c = list(map(int, input().split()))
	a = list(map(int, input().split()))
	for i in range(n):
		if len(a) > 0 and c[i] <= a[0]:
			a.pop(0)
	print(m - len(a))
while TN != 0:
	solution()
	TN -= 1


rd = lambda : list(map(int, input().split()))
(n, m) = rd()
(c, a) = (rd(), rd())
j = 0
r = 0
for i in range(n):
	if j >= m:
		break
	if a[j] >= c[i]:
		r += 1
		j += 1
print(r)


input()
c = [int(a) for a in input().split()]
a = [int(a) for a in input().split()]
count = 0
for i in c:
	if len(a) > 0 and i <= a[0]:
		count += 1
		a.pop(0)
print(count)


(n, m) = [int(x) for x in input().strip().split()]
c = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
ptrc = 0
ptra = 0
lc = len(c)
la = len(a)
cnt = 0
while ptrc < lc and ptra < la:
	if c[ptrc] <= a[ptra]:
		cnt += 1
		ptrc += 1
		ptra += 1
	else:
		ptrc += 1
print(cnt)


(n, m) = map(int, input().split())
pull = 0
a = list(map(int, input().split()))
b = list(map(int, input().split()))
while len(a) != 0:
	if len(b) != 0:
		if a[0] <= b[0]:
			a = a[1:]
			b = b[1:]
			pull += 1
		else:
			a = a[1:]
	else:
		break
print(pull)


a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
j = 0
count = 0
i = 0
while i < a[0] and j < a[1]:
	if c[j] >= b[i]:
		j += 1
		count += 1
	i += 1
print(count)


(n, m) = map(int, input().split())
cost = list(map(int, input().split()))
bill = list(map(int, input().split()))
j = 0
count = 0
for i in range(n):
	if cost[i] <= bill[j]:
		count += 1
		j += 1
	if i >= n or j >= m:
		break
print(count)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = 0
y = 0
c = 0
while x != n and y != m:
	if a[x] <= b[y]:
		c += 1
		x += 1
		y += 1
	else:
		x += 1
print(c)


(totalGames, totalBills) = list(map(int, input().split(' ')))
games = list(map(int, input().split(' ')))
bills = list(map(int, input().split(' ')))
(bought, game, bill) = (0, 0, 0)
while bill < totalBills and game < totalGames:
	if games[game] <= bills[bill]:
		bought += 1
		bill += 1
	game += 1
print(bought)


(n, m) = map(int, input().split())
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
j = 0
cnt = 0
for i in range(n):
	if c[i] <= a[j]:
		cnt += 1
		j += 1
		if j >= m:
			break
print(cnt)


input()
sto = input().split()
sto = [int(x) for x in sto]
bill = input().split()
bill = [int(x) for x in bill]
so = len(bill)
for s in sto:
	if len(bill) > 0:
		if bill[0] >= s:
			bill = bill[1:]
print(so - len(bill))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
k = 0
for i in range(n):
	if m != 0 and a[0] >= c[i]:
		del a[0]
		m -= 1
		k += 1
print(k)


(n, m) = map(int, input().split())
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
count = j = 0
if n >= m:
	x = n
else:
	x = m
for i in range(x):
	if j == m or i == n:
		break
	if a[j] >= c[i]:
		j += 1
		count += 1
print(count)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
a_i = 0
games = 0
for (i, current_game) in enumerate(c):
	if a_i >= m:
		break
	if a[a_i] >= current_game:
		games += 1
		a_i += 1
	else:
		continue
print(games)


[n, m] = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

def f(prix, portefeuille):
	if portefeuille == [] or prix == []:
		return 0
	elif prix[0] > portefeuille[0]:
		return f(prix[1:], portefeuille)
	else:
		return 1 + f(prix[1:], portefeuille[1:])
print(f(c, a))


(n, m) = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
has = a[0]
numws = 0
rjes = 0
for i in range(len(c)):
	if c[i] <= has:
		rjes += 1
		numws += 1
		if numws >= m:
			has = 0
		else:
			has = a[numws]
print(rjes)


s = input().split()
n = int(s[0])
m = int(s[1])
c = list(map(int, input().split()))
b = list(map(int, input().split()))
b_idx = c_idx = 0
cnt = 0
while c_idx < len(c) and b_idx < len(b):
	if b[b_idx] >= c[c_idx]:
		cnt += 1
		b_idx += 1
	c_idx += 1
print(cnt)


def main():
	(n, m) = map(int, input().split(' '))
	c = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	a.reverse()
	c.reverse()
	ans = 0
	while a and c:
		if a[-1] >= c[-1]:
			ans += 1
			a.pop()
		c.pop()
	print(ans)
main()


(n, m) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

def f(n, m, a, c):
	r = 0
	index = 0
	for i in range(n):
		if a[index] >= c[i]:
			r += 1
			index += 1
			if index == m:
				print(r)
				return
	print(r)
f(n, m, a, c)


(n, m) = map(int, input().split())
clst = list(map(int, input().split()))
alst = list(map(int, input().split()))
ind1 = ind2 = 0
ans = 0
for i in range(m):
	for j in range(ind2, n):
		if alst[i] >= clst[j]:
			ind2 = j + 1
			ans += 1
			break
	else:
		break
print(ans)


(n, m) = list(map(int, input().split()))
c = list(map(int, input().split()))
a = list(map(int, input().split()))
k = 0
i = 0
while i <= n - 1 and len(a) > 0:
	if a[0] >= c[i]:
		del a[0]
		k += 1
	i += 1
print(k)


(n, m) = [int(s) for s in input().split(' ')]
c = [int(s) for s in input().split(' ')]
a = [int(s) for s in input().split(' ')]
purchased = 0
for game in c:
	if len(a) == 0:
		break
	elif a[0] >= game:
		purchased += 1
		a = a[1:]
print(purchased)


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
(a, b) = (list(map(int, stdin.readline().split())), list(map(int, stdin.readline().split())))
cur = 0
ans = 0
for i in range(m):
	if cur == n:
		break
	while cur < n and a[cur] > b[i]:
		cur += 1
	if cur < n:
		ans += 1
		cur += 1
stdout.write(str(ans))


s = input()
o = input()
p = input()
sayi = list(s.split())
oyun = list(o.split())
para = list(p.split())
t = 0
n = 0
while n < len(oyun) and n < len(para):
	if int(para[n]) >= int(oyun[n]):
		t = t + 1
	else:
		oyun.pop(n)
		n = n - 1
	n = n + 1
print(t)


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
k = 0
s = 0
for i in range(len(a)):
	if b[k] >= a[i]:
		k += 1
		s += 1
		if s == m:
			break
print(s)


(n, m) = [int(i) for i in input().split()]
ig = [int(i) for i in input().split()]
k = [int(i) for i in input().split()]
t = 0
(j, r) = (0, 0)
while r < m and j < n:
	if k[r] >= ig[j]:
		r += 1
		j += 1
		t += 1
	else:
		j += 1
print(t)


def gamecount(c, a, m):
	count = 0
	for i in range(len(c)):
		if a[0] >= c[i]:
			a.remove(a[0])
			count += 1
		if count == m:
			break
	return count
(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
print(gamecount(c, a, m))


import time
from copy import deepcopy
import itertools
from bisect import bisect_left
from bisect import bisect_right
import math
from collections import deque
from collections import Counter

def read():
	return int(input())

def readmap():
	return map(int, input().split())

def readlist():
	return list(map(int, input().split()))
(n, m) = readmap()
C = readlist()
A = readlist()
A.reverse()
ans = 0
for i in range(n):
	if A:
		if C[i] <= A[-1]:
			ans += 1
			A.pop()
print(ans)


[n, m] = [int(i) for i in input().split()]
costs = [int(i) for i in input().split()]
bills = [int(i) for i in input().split()]
start = 0
out = 0
for i in range(n):
	if start < m:
		if costs[i] <= bills[start]:
			out += 1
			start += 1
	else:
		break
print(out)


(n, m) = map(int, input().split())
n1 = list(map(int, input().split()))
m1 = list(map(int, input().split()))
c = 0
f = m1[0]
k = 0
for i in range(n):
	if k == m - 1:
		if f >= n1[i]:
			c = c + 1
			break
	if f >= n1[i]:
		k = k + 1
		f = m1[k]
		c = c + 1
print(c)


(n, m) = input().split()
n = int(n)
m = int(m)
sum = 0
c = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
for i in range(n):
	if len(a) == 0:
		break
	if c[i] > a[0]:
		continue
	else:
		sum += 1
		a.remove(a[0])
		continue
print(sum)


(n, m) = map(int, input().split())
shu1 = input()
shu2 = input()
a = [int(i) for i in shu1.split(' ')]
b = [int(i) for i in shu2.split(' ')]
ans = 0
for i in a:
	if b[ans] >= i:
		ans += 1
	if ans == m:
		break
print(ans)


(n, m) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = 0
for x in c:
	if ans < m and x <= a[ans]:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
cost = list(map(int, input().split()))
bill = list(map(int, input().split()))
ans = 0
bill.reverse()
for c in cost:
	if bill:
		if bill[-1] >= c:
			bill.pop()
			ans += 1
print(ans)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
(ans, st) = (0, 0)
for i in range(n):
	if a[st] >= c[i]:
		ans += 1
		st += 1
	if st >= m:
		break
print(ans)


(n, m) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
i = 0
k = 0
res = 0
while i < n and k < m:
	while a[k] < c[i]:
		i += 1
		if i == n:
			break
	if i == n:
		break
	i += 1
	res += 1
	k += 1
print(res)


(c, m) = [int(i) for i in input().strip().split()]
cost = [int(i) for i in input().strip().split()]
bills = [int(i) for i in input().strip().split()]
count = 0
b = 0
for c_i in cost:
	if c_i <= bills[b]:
		count += 1
		b += 1
	if b == m:
		break
print(count)


from sys import stdin, stdout
input = lambda : stdin.readline().rstrip()
write = stdout.write

def main():
	(N, M) = map(int, input().split())
	C = tuple(map(int, input().split()))
	A = tuple(map(int, input().split()))
	(i, cnt) = (0, 0)
	for bill in A:
		while i < N:
			if bill >= C[i]:
				cnt += 1
				i += 1
				break
			i += 1
	print(cnt)
main()


input().split()
c = list(map(int, input().split()))
a = list(map(int, input().split()))
counter = 0
i = 0
j = 0
while j < len(c) and i < len(a):
	if a[i] >= c[j]:
		counter += 1
		(i, j) = (1 + i, 1 + j)
	elif a[i] < c[j]:
		j += 1
print(counter)


import math

def main():
	(n, m) = map(int, input().split())
	c = list(map(int, input().split()))
	a = list(map(int, input().split()))
	i = j = co = 0
	while j < len(a):
		if i == len(c):
			break
		if a[j] >= c[i]:
			co += 1
			j += 1
		i += 1
	print(co)
main()


(a, b) = list(map(int, input().split()))
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
pos = 0
for i in aa:
	if pos >= b:
		break
	if bb[pos] >= i:
		pos += 1
print(pos)


s = input()
n = int(s.split(' ')[0])
m = int(s.split(' ')[1])
s1 = input()
s2 = input()
c = s1.split(' ')
a = s2.split(' ')
amount = 0
for el in c:
	if len(a) > 0:
		if int(el) <= int(a[0]):
			a.remove(a[0])
			amount += 1
	else:
		break
print(amount)


def I():
	return map(int, input().split())
(n, m) = I()
c = list(I())
a = list(I())
i = 0
j = 0
ans = 0
while i < len(c) and j < len(a):
	if c[i] <= a[j]:
		i += 1
		j += 1
		ans += 1
	else:
		i += 1
print(ans)


def go():
	(n, m) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	i = j = 0
	while i < n and j < m:
		if a[i] <= b[j]:
			j += 1
		i += 1
	return j
print(go())


(n, m) = map(int, input().split())
nl = list(map(int, input().split()))
ml = list(map(int, input().split()))
(i, count) = (0, 0)
for j in range(n):
	if nl[j] <= ml[i]:
		count += 1
		i += 1
	if i == m:
		break
print(count)


(x, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
v = 0
for i in range(x):
	if b[v] >= a[i]:
		v += 1
	if v == len(b):
		break
print(v)


(n, m) = map(int, input().split())
games = list(map(int, input().split()))
money = list(map(int, input().split()))
current = 0
i = 0
s = 0
while i != len(games):
	if games[i] <= money[current]:
		s += 1
		current += 1
	if current == len(money):
		break
	i += 1
print(s)


(n, m) = map(int, input().split())
costs = list(map(int, input().split()))
bills = list(map(int, input().split()))
num = 0
currentBill = bills.pop(0)
while len(costs) > 0:
	try:
		currentGame = costs.pop(0)
		if currentBill >= currentGame:
			num = num + 1
			currentBill = bills.pop(0)
	except IndexError:
		break
print(num)


import sys
import bisect
from collections import Counter
read_int = lambda : int(sys.stdin.readline())
read_ints = lambda : map(int, sys.stdin.readline().split())
read_int_list = lambda : list(read_ints())
read = lambda : sys.stdin.readline().strip()
read_list = lambda : sys.stdin.readline().split()

def main():
	(n, m) = read_ints()
	c = read_int_list()
	a = read_int_list()
	(i, j) = (0, 0)
	res = 0
	while i < n and j < m:
		if c[i] <= a[j]:
			res += 1
			i += 1
			j += 1
		else:
			i += 1
	print(res)
main()


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
h = list(map(int, input().split()))
j = 0
k = 0
for i in range(n):
	if j == len(h):
		break
	if s[i] <= h[j]:
		k += 1
		j += 1
print(k)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
zero1 = 0
zero2 = 0
for i in a:
	if zero2 < m and i <= b[zero2]:
		zero1 += 1
		zero2 += 1
print(zero1)


input()
arr1 = [int(i) for i in input().split()]
arr2 = [int(i) for i in input().split()]
index1 = 0
counter = 0
for i in arr1:
	try:
		if i <= arr2[index1]:
			counter += 1
			index1 += 1
	except:
		break
print(counter)


(x, y) = map(int, input().split())
c = map(int, input().split())
a = map(int, input().split())
counter = 0
for i in a:
	for j in c:
		if j <= i:
			counter += 1
			break
print(counter)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
i = 0
j = 0
ans = 0
while i < n and j < m:
	while a[j] < c[i]:
		i += 1
		if i + 1 > n:
			break
	if i < n:
		ans += 1
	i += 1
	j += 1
print(ans)


(n, m) = map(int, input().split(' '))
C = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
cnt = 0
for i in C:
	if A == []:
		break
	if A[0] >= i:
		cnt += 1
		del A[0]
print(cnt)


def gamesCount(costs, bills):
	(i, j) = (0, 0)
	while i < len(costs) and j < len(bills):
		if costs[i] <= bills[j]:
			j += 1
		i += 1
	return j
(n, m) = map(int, input().split())
costs = list(map(int, input().split()))
bills = list(map(int, input().split()))
print(gamesCount(costs, bills))


input().split()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
count = 0
i = 0
j = 0
while i < len(a) and j < len(b):
	if b[j] >= a[i]:
		count += 1
		j += 1
		i += 1
	elif b[j] < a[i]:
		i += 1
print(count)


(n, m) = input().split(' ')
c = input().split(' ')
w = input().split(' ')
counter = 0
for i in c:
	if w != [] and int(i) <= int(w[0]):
		counter = counter + 1
		w.remove(w[0])
print(counter)


def solution(l1, l2, l3):
	(n, m) = (l1[0], l1[1])
	costs = l2
	bills = l3
	i = 0
	ans = 0
	while i < len(costs):
		if len(bills) == 0:
			break
		else:
			bill = bills[0]
		if bill >= costs[i]:
			ans += 1
			bills.remove(bill)
		i += 1
	return ans

def answer():
	l1 = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	l3 = [int(x) for x in input().split()]
	print(solution(l1, l2, l3))
answer()


(n, m) = list(map(int, input().strip().split(' ')))
cost = list(map(int, input().strip().split(' ')))
arr = list(map(int, input().strip().split(' ')))
i = 0
j = 0
gifts = 0
while i < n and j < m:
	if arr[j] >= cost[i]:
		gifts += 1
		j += 1
	i += 1
print(gifts)


IL = lambda : list(map(int, input().split()))
(n, m) = IL()
G = IL()
B = IL()
ans = 0
i = 0
for b in B:
	while i < n and G[i] > b:
		i += 1
	if i == n:
		break
	if b >= G[i]:
		ans += 1
		i += 1
print(ans)


(n, m) = map(int, input().split())
C = list(map(int, input().split()))
A = list(map(int, input().split())) + [-1]
ans = 0
j = 0
for i in range(n):
	if C[i] <= A[j] and j <= m - 1:
		j += 1
		ans += 1
print(ans)


(g, b) = map(int, input().split())
g1 = list(map(int, input().split()))
b1 = list(map(int, input().split()))
c = 0
l = []
for i in range(g):
	if i not in l:
		l.append(i)
		if b1[c] >= g1[i]:
			c += 1
			if c == b:
				break
print(c)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
t = 0
while len(a) > 0 and len(b) > 0:
	if a[0] <= b[0]:
		a.pop(0)
		b.pop(0)
		t += 1
	else:
		a.pop(0)
print(t)


(c, a) = tuple(map(int, input().split()))
toy = list(map(int, input().split()))
wallet = list(map(int, input().split()))
count = 0
i = 0
for so in toy:
	if so <= wallet[i] and i < a - 1:
		count += 1
		i += 1
	elif i == a - 1 and so <= wallet[i]:
		count += 1
		break
print(count)


(n, m) = map(int, input().split())
cost = list(map(int, input().split()))
bills = list(map(int, input().split()))
(i, j) = (0, 0)
while i < n and j < m:
	if bills[j] >= cost[i]:
		i += 1
		j += 1
	else:
		i += 1
print(j)


(n, m) = [int(x) for x in input().split()]
g = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
b.append(-1)
idx = 0
game = 0
for x in g:
	if x <= b[idx]:
		idx += 1
		game += 1
print(game)


l = lambda : map(int, input().split())
(n, m) = l()
C = list(l())
A = list(l())
c = 0
j = 0
for i in C:
	if j < m and i <= A[j]:
		c += 1
		j += 1
print(c)


import math

def main():
	(n, m) = list(map(int, input().split()))
	games = list(map(int, input().split()))
	bills = list(map(int, input().split()))
	(i, j, count) = (0, 0, 0)
	while i < n and j < m:
		if games[i] <= bills[j]:
			count += 1
			i += 1
			j += 1
		else:
			i += 1
	print(count)
main()


(len_games, len_bills) = [int(x) for x in input().split()]
costArrays = [int(x) for x in input().split()]
billsArrays = [int(x) for x in input().split()]
gameCounts = 0
index = 0
for bills in billsArrays:
	while index < len_games:
		if bills >= costArrays[index]:
			index += 1
			gameCounts += 1
			break
		index += 1
print(gameCounts)


from sys import stdin
from math import *
line = stdin.readline().rstrip().split()
n = int(line[0])
m = int(line[1])
games = list(map(int, stdin.readline().rstrip().split()))
bills = list(map(int, stdin.readline().rstrip().split()))
countM = 0
countN = 0
while countN < n and countM < m:
	if games[countN] <= bills[countM]:
		countM += 1
	countN += 1
print(countM)


[n, m] = input().split()
n = int(n)
games = input().split()
money = input().split()
(answer, i) = (0, 0)
while len(money) > 0:
	while int(games[i]) > int(money[0]) and i < n - 1:
		i += 1
	if i == n - 1:
		if int(games[i]) <= int(money[0]):
			answer += 1
		break
	money.pop(0)
	answer += 1
	i += 1
print(answer)


from sys import stdin, stdout

def rint():
	return list(map(int, stdin.readline().split()))
(n, m) = rint()
c = list(rint())
a = list(rint())
j = 0
cnt = 0
for i in range(n):
	if j >= m:
		break
	if c[i] <= a[j]:
		cnt += 1
		j += 1
print(cnt)


(n, m) = [int(s) for s in input().split(' ')]
games = [int(s) for s in input().split(' ')]
geld = [int(s) for s in input().split(' ')]
result = 0
for game in games:
	if geld and geld[0] >= game:
		geld.pop(0)
		result += 1
print(result)


count = input().split()
n = int(count[0])
m = int(count[1])
x = 0
j = 0
games = []
bills = []
games = input().split()
bills = input().split()
for i in range(n):
	c = int(games[i])
	if j < m:
		a = int(bills[j])
	if j == m:
		break
	if a >= c:
		x = x + 1
		i = i + 1
		j = j + 1
print(x)


(a, b) = map(int, input().split())
t1 = 0
t2 = 0
j = 0
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for i in range(len(y)):
	k = 0
	while j <= len(x) - 1:
		if x[j] <= y[i]:
			t1 = t1 + 1
			j = j + 1
			break
		elif x[j] > y[i]:
			j = j + 1
if t1 != 0:
	print(t1)
else:
	print(t1)


(n, m) = map(int, input().split())
c = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
u = 0
for t in range(n):
	if c[0] <= a[0]:
		u += 1
		del a[0]
		m -= 1
		if m == 0:
			break
	del c[0]
print(u)


def main():
	rd = lambda : list(map(int, input().split()))
	(n, m) = rd()
	ga = rd()
	bi = rd()
	i = j = cnt = 0
	while i < len(ga) and j < len(bi):
		if ga[i] <= bi[j]:
			cnt += 1
			i += 1
			j += 1
		else:
			i += 1
	print(cnt)
main()


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
k = 0
for i in range(m):
	test = True
	for j in range(n):
		if a[i] >= c[j] and c[j] != -1 and test:
			k += 1
			c[j] = -1
			test = False
		elif test:
			c[j] = -1
print(k)


no = input()
game = input().split()
bill = input().split()
for i in range(len(game)):
	game[i] = int(game[i])
for i in range(len(bill)):
	bill[i] = int(bill[i])
result = 0
j = 0
i = 0
while True:
	if i >= len(game) or j >= len(bill):
		break
	if game[i] <= bill[j]:
		i += 1
		j += 1
		result += 1
	else:
		i += 1
print(result)


(n, m) = map(int, input().split())
C = [*map(int, input().split())]
A = [*map(int, input().split())]
ap = 0
cp = 0
cc = 0
while cp < len(C) and ap < len(A):
	if A[ap] >= C[cp]:
		ap += 1
		cc += 1
	cp += 1
print(cc)


def main():
	(n, m) = [int(x) for x in input().split()]
	g = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	count = 0
	for i in g:
		if i <= a[count]:
			count += 1
			if count == len(a):
				break
	print(count)

def __starting_point():
	main()
__starting_point()


from collections import deque
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
B = deque(B)
cnt = 0
for i in range(n):
	if B[0] >= A[i]:
		cnt += 1
		B.popleft()
	if cnt == min(n, m):
		print(cnt)
		exit(0)
print(cnt)


(n, m) = map(int, input().split())
li = list(map(int, input().split()))
li1 = list(map(int, input().split()))
j = 0
count = 0
i = 0
while j < len(li) and i < len(li1):
	if li[j] <= li1[i]:
		count += 1
		j += 1
		i += 1
	else:
		j += 1
print(count)


def main():
	(n, m) = [int(v) for v in input().split()]
	vals1 = [int(v) for v in input().split()]
	vals2 = [int(v) for v in input().split()]
	cur = 0
	c = 0
	for i in range(n):
		if cur < m:
			if vals2[cur] >= vals1[i]:
				c += 1
				cur += 1
	print(c)
main()


input()
c = list(map(int, input().split()))
a = list(map(int, input().split()))
i = 0
s = 0
for K in c:
	if i >= len(a):
		break
	if a[i] >= K:
		s += 1
		i += 1
print(s)


(n, m) = input().split()
n = int(n)
m = int(m)
c = input().split(' ')
for i in range(n):
	c[i] = int(c[i])
a = input().split(' ')
for i in range(m):
	a[i] = int(a[i])
i = 0
count = 0
for k in range(n):
	if i < m:
		if a[i] >= c[k]:
			count = count + 1
			i = i + 1
print(count)


nothing = input().split()
costs = input().split()
moneys = input().split()
a = 0
for i in costs:
	if a == len(moneys):
		break
	money = moneys[a]
	if int(i) <= int(money):
		a += 1
print(a)


(n, m) = list(map(int, input().split()))
c = list(map(int, input().split()))
a = list(map(int, input().split()))
bought_games = 0
ci = 0
ai = 0
while ci < len(c) and ai < len(a):
	if a[ai] >= c[ci]:
		bought_games += 1
		ai += 1
	ci += 1
print(bought_games)


input_nm = input().split(' ')
games = input().split(' ')
money = input().split(' ')
start_g = 0
count = 0
money = [int(item) for item in money]
games = [int(item) for item in games]
for now in games:
	if now <= money[start_g]:
		count = count + 1
		if start_g < int(input_nm[1]) - 1:
			start_g = start_g + 1
		else:
			break
print(count)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
m = list(map(int, input().split()))
count = 0
k = 0
for i in range(len(m)):
	j = k
	f = 0
	while j < n:
		if m[i] >= l[j]:
			k = j + 1
			count += 1
			f = 1
			break
		j += 1
	if f == 0:
		break
print(count)


(n, m) = map(int, input().split())
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
count = 0
while len(c) > 0 and len(a) > 0:
	game = c.pop(0)
	if a[0] >= game:
		a.pop(0)
		count += 1
print(count)


(pocHier, pocPen) = list(map(int, input().split()))
hry = list(map(int, input().split()))
pen = list(map(int, input().split()))
(sucasCisPen, vys) = (0, 0)
for i in range(pocHier):
	if pen[sucasCisPen] >= hry[i]:
		vys += 1
		sucasCisPen += 1
	if sucasCisPen >= pocPen:
		break
print(vys)


def buy_games(costs, bills):
	buy = 0
	j = 0
	for (i, c) in enumerate(costs):
		if bills[j] >= c:
			buy += 1
			j += 1
		if j >= len(bills):
			break
	return buy
(n, m) = [int(x) for x in input().split()]
costs = [int(x) for x in input().split()]
bills = [int(x) for x in input().split()]
print(buy_games(costs, bills))


(n, m) = map(int, input().split())
n1 = list(map(int, input().split()))
m1 = list(map(int, input().split()))
count = 0
for i in range(len(n1)):
	if len(m1) == 0:
		break
	elif m1[0] >= n1[i]:
		count += 1
		m1.remove(m1[0])
print(count)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
(n, m) = get_list()
cost = get_list()
bills = [*get_list()] + [0]
buy = 0
pos = 0
for i in cost:
	if i <= bills[pos]:
		pos += 1
		buy += 1
print(buy)


from collections import deque
(n, m) = [int(x) for x in input().split()]
games = [int(x) for x in input().split()]
cash = [int(x) for x in input().split()]
cash = deque(cash)
count = 0
for g in games:
	if cash:
		current = cash[0]
		if current >= g:
			cash.popleft()
			count += 1
print(count)


(n, m) = map(int, input().split())
temp1 = list(input().split())
temp2 = list(input().split())
for i in range(n):
	temp1[i] = int(temp1[i])
for i in range(m):
	temp2[i] = int(temp2[i])
count = 0
for q in range(n):
	if temp2 == []:
		print(count)
		exit()
	elif temp2[0] >= temp1[q]:
		del temp2[0]
		count += 1
print(count)


def shopping(n, m, costs, bills):
	count = 0
	for val in costs:
		if len(bills) == 0:
			break
		elif val <= bills[0]:
			count += 1
			bills.pop(0)
	print(count)
rd = lambda : [int(x) for x in input().split(' ')]
(n, m) = rd()
costs = rd()
bills = rd()
shopping(n, m, costs, bills)


(number_of_game, number_of_bill) = map(int, input().split())
game_cost = list(map(int, input().split()))
bill_value = list(map(int, input().split()))
game_have_benn_bughut = 0
tag = 0
for i in range(number_of_game):
	if bill_value == []:
		print(game_have_benn_bughut)
		tag = 1
		break
	if game_cost[i] <= bill_value[0]:
		game_have_benn_bughut += 1
		del bill_value[0]
if tag == 0:
	print(game_have_benn_bughut)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
	if len(b) == 0:
		break
	if b[0] >= c[i]:
		ans += 1
		b.pop(0)
print(ans)


def igry(c, a, m):
	k = 0
	for i in range(len(c)):
		if k < m and a[k] >= c[i]:
			k += 1
	return k
(N, M) = [int(j) for j in input().split()]
C = [int(x) for x in input().split()]
A = [int(y) for y in input().split()]
print(igry(C, A, M))


(games, bills) = [int(x) for x in input().split()]
games_cost = [int(x) for x in input().split()]
has_bill = [int(x) for x in input().split()]
cnt = 0
for g in games_cost:
	if g <= has_bill[0]:
		has_bill.pop(0)
		cnt += 1
	if len(has_bill) < 1:
		break
print(cnt)


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ans = 0
for x in range(n):
	if a[x] <= b[ans]:
		ans += 1
		if ans >= m:
			break
print(ans)


nm = list(map(int, input().split()))
c = list(map(int, input().split()))
a = list(map(int, input().split()))
games = 0
for i in range(nm[0]):
	if len(a) > 0:
		if c[i] <= a[0]:
			games += 1
			a.pop(0)
	else:
		break
print(games)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
i = 0
result = 0
for elem in a:
	if i >= len(b):
		break
	if elem <= b[i]:
		result += 1
		i += 1
print(result)


from collections import Counter, defaultdict, deque
read = lambda : list(map(int, input().split()))
getinfo = lambda grid: print(list(map(print, grid)))
p = lambda x: print(x, end=' ')
mod = 10 ** 9 + 7
inf = float('inf')
while True:
	try:
		(n, m) = read()
		c = read()[::-1]
		a = read()[::-1]
		res = 0
		while len(c) > 0 and len(a) > 0:
			if a[-1] >= c[-1]:
				a.pop()
				res += 1
			c.pop()
		print(res)
	except:
		break


(n, m) = input().split()
cost_Array = list(map(int, input().split()))
bill_Array = list(map(int, input().split()))
i = 0
j = 0
count = 0
while i < int(n) and j < int(m):
	if cost_Array[i] <= bill_Array[j]:
		count += 1
		i += 1
		j += 1
	else:
		i += 1
print(count)


(n, m) = map(int, input().split())
i = [int(x) for x in input().split()]
j = [int(x) for x in input().split()]
games = 0
a = 0
b = 0
while a < len(i) and b < len(j):
	if j[b] >= i[a]:
		games += 1
		a += 1
		b += 1
	else:
		a += 1
print(games)


import atexit, io, sys
buffer = io.StringIO()
sys.stdout = buffer

@atexit.register
def write():
	sys.__stdout__.write(buffer.getvalue())
from sys import stdin, stdout
from collections import deque

def main():
	_ = stdin.readline()
	costo_juegos = (int(n) for n in stdin.readline().split())
	billetera = deque([int(n) for n in stdin.readline().split()])
	cont = 0
	while billetera:
		try:
			if billetera[0] >= costo_juegos.__next__():
				billetera.popleft()
				cont += 1
		except StopIteration:
			break
	stdout.write('%d\n' % cont)
main()


(n, m) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
k = 0
for i in range(len(c)):
	if a != []:
		if a[0] >= c[i]:
			k += 1
			a.pop(0)
print(k)


r = lambda : map(int, input().split())
r()
(a, b) = (r(), [*r()] + [0])
s = 0
for i in a:
	s += i <= b[s]
print(s)


(n, m) = map(int, input().split(' '))
cline = input().split(' ')
aline = input().split(' ')
c = [int(i) for i in cline]
a = [int(i) for i in aline]
cnt = 0
j = 0
anow = a[j]
for i in c:
	if i <= anow:
		cnt += 1
		j += 1
		if j < m:
			anow = a[j]
		else:
			break
	elif j < m:
		anow = a[j]
	else:
		break
print(cnt)


(n, m) = map(int, input().split(' '))
cost = list(map(int, input().split(' ')))
arr = list(map(int, input().split(' ')))
j = 0
ans = 0
for i in range(n):
	if j > m - 1:
		break
	if arr[j] >= cost[i]:
		j += 1
		ans += 1
print(ans)


nm = list(map(int, input(' ').split(' ')))
n = nm[0]
m = nm[1]
c = list(map(int, input(' ').split(' ')))
a = list(map(int, input(' ').split(' ')))
l = 0
ans = 0
for i in range(n):
	if c[i] <= a[l]:
		l += 1
		ans += 1
	if l == len(a):
		break
print(ans)


(n, m) = list(map(int, input().split()))
c = list(map(int, input().split()))
a = list(map(int, input().split()))
s = tuple(a)
ans = 0
for i in range(len(c)):
	if len(a) == 0:
		print(len(s))
		exit()
	if a[0] >= c[i]:
		a.pop(0)
		ans += 1
print(ans)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
game = bill = 0
while game < n and bill < m:
	if a[bill] >= c[game]:
		bill += 1
	game += 1
print(bill)


def main():
	[n_games, n_bills] = [int(_) for _ in input().split()]
	game_prices = [0] + [int(_) for _ in input().split()]
	bills = [0] + [int(_) for _ in input().split()]
	last_game = 0
	last_bill = 0
	count_games_bought = 0
	while last_game < n_games and last_bill < n_bills:
		last_bill += 1
		bill = bills[last_bill]
		try:
			last_game = next((g for g in range(last_game + 1, n_games + 1) if game_prices[g] <= bill))
			count_games_bought += 1
		except StopIteration:
			last_game = n_games
	print(count_games_bought)
main()


(N, M) = map(int, input().split())
L = list(map(int, input().split()))
S = list(map(int, input().split()))
count = 0
j = 0
for i in range(N):
	if j < M:
		if S[j] >= L[i]:
			j += 1
			count += 1
print(count)


(n, m) = input().split(' ')
c = input().split(' ')
b = input().split(' ')
count = 0
for i in c:
	if b != [] and int(i) <= int(b[0]):
		count += 1
		del b[0]
print(count)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
for k in c:
	if not a:
		break
	if a[0] >= k:
		ans += 1
		a.pop(0)
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
k = 0
cnt = 0
for i in range(len(a)):
	if len(b) == k:
		break
	if b[k] >= a[i]:
		cnt += 1
		k += 1
print(cnt)


import math
import sys
(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
(j, res) = (0, 0)
for i in range(n):
	good = True
	if j == m:
		break
	if b[j] >= a[i]:
		res += 1
		j += 1
		continue
print(res)


input()
a = list(map(int, input().split()))[::-1]
b = list(map(int, input().split()))[::-1]
ans = 0
while a and b:
	if a.pop() <= b[-1]:
		b.pop()
		ans += 1
print(ans)


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
d = list(map(int, input().split()))
(i, j) = (0, 0)
while i <= a - 1 and j <= b - 1:
	if c[i] <= d[j]:
		i += 1
		j += 1
	else:
		i += 1
print(j)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
from collections import deque
(n, m) = get_list()
cost = deque(get_list())
bills = deque(get_list())
buy = 0
for i in cost:
	if len(bills) > 0:
		first_bill = bills.popleft()
		if i <= first_bill:
			buy += 1
		else:
			bills.appendleft(first_bill)
	else:
		break
print(buy)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
r = 0
w = 0
for i in range(n):
	if w >= len(a):
		break
	if c[i] <= a[w]:
		w += 1
		r += 1
print(r)


(n, m) = list(map(int, input().split()))
c = list(map(int, input().split()))
a = list(map(int, input().split()))
games = 0
for price in c:
	if len(a) > 0:
		if a[0] >= price:
			games += 1
			a.pop(0)
	elif price == 0:
		games += 1
print(games)


input()
games = [int(x) for x in input().split()]
wallet = [int(x) for x in input().split()]
numgames = 0
for game in games:
	if len(wallet):
		if wallet[0] >= game:
			del wallet[0]
			numgames += 1
	else:
		break
print(numgames)


(n, m) = map(int, input().split())
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a_pointer = 0
count = 0
for i in c:
	try:
		if i <= a[a_pointer]:
			count += 1
			a_pointer += 1
	except:
		break
print(count)


(cn, pn) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
j = 0
ans = 0
for i in range(cn):
	if p[j] >= c[i]:
		j += 1
		ans += 1
		if j == pn:
			break
		continue
print(ans)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
i = 0
for bill in a:
	try:
		i += next((ind for (ind, el) in enumerate(c[i:]) if el <= bill)) + 1
		ans += 1
	except StopIteration:
		break
print(ans)


str = input()
strA = str.split(' ')
n = int(strA[0])
m = int(strA[1])
StrN = input()
StrM = input()
sln = StrN.split(' ')
slm = StrM.split(' ')
ln = list()
lm = list()
for i in range(0, n):
	ln.append(int(sln[i]))
for j in range(0, m):
	lm.append(int(slm[j]))
c = 0
c2 = 0
tB = 0
flg = False
while c < n:
	flg = False
	if c2 >= m or c > n:
		break
	if lm[c2] >= ln[c]:
		flg = True
		c2 += 1
		tB += 1
	c += 1
print(tB)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
i = 0
for t in c:
	if i == m:
		break
	if a[i] >= t:
		i += 1
print(i)


(n, m) = map(int, input().split())
games = list(map(int, input().split()))
wallet = list(map(int, input().split()))
s = 0
for val in range(0, len(games)):
	if len(wallet) > 0:
		if wallet[0] >= games[val]:
			wallet.remove(wallet[0])
			s += 1
print(s)


import atexit, io, sys
buffer = io.StringIO()
sys.stdout = buffer

@atexit.register
def write():
	sys.__stdout__.write(buffer.getvalue())
from sys import stdin, stdout

def main():
	_ = stdin.readline()
	entrada = stdin.readlines()
	(costo_juegos, billetera) = [[int(o) for o in n.split()] for n in entrada]
	cont = 0
	for juego in costo_juegos:
		if billetera:
			if billetera[0] >= juego:
				cont += 1
				billetera.pop(0)
	stdout.write(str(cont))
main()


R = lambda : map(int, input().split())
R()
(c, a) = (R(), R())
r = 0
try:
	for x in a:
		r += next((1 for y in c if y <= x))
except:
	pass
print(r)


nm = list(map(int, input().strip().split()))
n = nm[0]
m = nm[1]
costs = list(map(int, input().strip().split()))
wallet = list(map(int, input().strip().split()))
count = 0
for cost in costs:
	if wallet:
		if cost <= wallet[0]:
			count += 1
			wallet.pop(0)
	else:
		break
print(count)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
(i, j, cnt) = (0, 0, 0)
while True:
	if i > n - 1 or j > m - 1:
		break
	if c[i] <= a[j]:
		cnt += 1
		j += 1
	i += 1
print(cnt)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
total = 0
apos = 0
for cost in c:
	if apos < m:
		if a[apos] < cost:
			pass
		else:
			total += 1
			apos += 1
print(total)


(n, m) = map(int, input().split())
ln = list(map(int, input().split()))
lm = list(map(int, input().split()))
n1 = 0
p = 0
for i in range(m):
	for j in range(p, n):
		if lm[i] >= ln[j]:
			p = j + 1
			n1 += 1
			break
		if j == n - 1:
			print(n1)
			exit()
print(n1)


from collections import deque
n = input()
c = input()
a = input()
n_l = deque([int(x) for x in n.split(' ')])
c_l = deque([int(x) for x in c.split(' ')])
a_l = deque([int(x) for x in a.split(' ')])
j = 0
for i in range(n_l[0]):
	if len(a_l) != 0 and c_l[i] <= a_l[0]:
		a_l.popleft()
		j += 1
print(j)


(n, m) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
j = 0
a.append(-1)
for i in c:
	if i <= a[j]:
		j = j + 1
print(j)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
(Pc, Pa, ans) = (0, 0, 0)
while Pc < n and Pa < m:
	if a[Pa] >= c[Pc]:
		ans += 1
		Pa += 1
		Pc += 1
	else:
		Pc += 1
print(ans)


(n, m) = map(int, input().split(' '))
game = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
z = 0
ans = 0
for i in range(n):
	if z < m and game[i] <= a[z]:
		z += 1
		ans += 1
print(ans)


(n, m) = map(int, input().split())
games = list(map(int, input().split()))
bills = list(map(int, input().split()))
bought = 0
for i in range(n):
	if bought < m and bills[bought] >= games[i]:
		bought += 1
print(bought)


(n, m) = map(int, input().split())
c = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
count = 0
for i in range(len(c)):
	if len(a) != 0 and a[0] >= c[i]:
		count += 1
		a.pop(0)
print(count)


(n, m) = map(int, input().split())
A = list(map(int, input().split(' ')[:n]))
B = list(map(int, input().split(' ')[:m]))
temp = ans = 0
for i in A:
	if B[temp] >= i:
		ans += 1
		temp += 1
	if temp == m:
		break
print(ans)


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
s1 = list(map(int, input().split()))
x = 0
ans = 0
y = 0
while x < n and y < m:
	if s[x] <= s1[y]:
		ans += 1
		y += 1
		x += 1
	else:
		x += 1
print(ans)


import sys, math, queue
MOD = 998244353
sys.setrecursionlimit(1000000)
(n, m) = map(int, input().split())
c = list(map(int, input().split()))
b = list(map(int, input().split()))
(i, ans) = (0, 0)
for ci in c:
	if i == m:
		break
	if b[i] >= ci:
		ans += 1
		i += 1
print(ans)


input()
p = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
m = len(b)
i = 0
for tmp in p:
	if tmp <= b[i]:
		ans += 1
		i += 1
		if i == m:
			break
print(ans)


def main():
	(n, m) = map(int, input().split())
	c = list(map(int, input().split()))
	a = list(map(int, input().split()))
	ind = 0
	g = 0
	ret = 0
	while ind < m and g < n:
		if c[g] <= a[ind]:
			ret += 1
			ind += 1
		g += 1
	print(ret)
	return 0
main()


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
d = list(map(int, input().split()))
c = 0
x = 0
for i in range(n):
	if d[x] >= l[i]:
		c = c + 1
		x = x + 1
	if x >= m:
		break
print(c)


xx = input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
t = 0
c = 0
for i in a:
	if t < len(b):
		if i <= b[t]:
			c += 1
			t += 1
print(c)


x = input().split()
z = input().split()
l = []
for i in range(len(z)):
	l.append(int(z[i]))
y = input().split()
m = []
for i in range(len(y)):
	m.append(int(y[i]))
n = j = 0
for i in range(len(l)):
	if m[j] >= l[i]:
		n += 1
		j += 1
	if j == len(m):
		break
print(n)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
res = 0
for i in c:
	res += res < len(a) and a[res] >= i
print(res)


(n, m) = [int(x) for x in input().split()]
game = [int(x) for x in input().split()]
bill = [int(x) for x in input().split()]
j = 0
count = 0
for i in range(len(game)):
	if game[i] <= bill[j]:
		count += 1
		j += 1
	if j == len(bill):
		break
print(count)


import functools
import time

def timer(func):

	@functools.wraps(func)
	def wrapper(*args, **kwargs):
		stime = time.perf_counter()
		res = func(*args, **kwargs)
		elapsed = time.perf_counter() - stime
		print(f'{func.__name__} in {elapsed:.4f} secs')
		return res
	return wrapper

class solver:

	def __init__(self):
		pass

	def __call__(self):
		(n, m) = map(int, input().strip().split())
		c = list(map(int, input().strip().split()))
		a = list(map(int, input().strip().split()))
		res = 0
		p = 0
		for ci in c:
			if p < m and ci <= a[p]:
				p += 1
				res += 1
		print(res)
solver()()


(a, b) = map(int, input().split())
c = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]
value = 0
l1 = 0
l2 = 0
val1 = c[0]
val2 = d[0]
while 1:
	if val2 >= val1:
		value += 1
		l2 += 1
		l1 += 1
		if l2 == b or l1 == a:
			break
		val2 = d[l2]
		val1 = c[l1]
	else:
		l1 += 1
		if l1 == a:
			break
		val1 = c[l1]
print(value)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
a.append(0)
for i in range(n):
	if c[i] <= a[0]:
		ans += 1
		a.pop(0)
print(ans)


(n, m) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = 0
for x in c:
	if ans < m:
		if x <= a[ans]:
			ans += 1
	else:
		break
print(ans)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
c.reverse()
a = list(map(int, input().split()))
a.reverse()
res = 0
for i in range(n - 1, -1, -1):
	if len(a) - 1 >= 0 and c[i] <= a[len(a) - 1]:
		a.pop()
		res += 1
print(res)


first = [int(x) for x in input().split()]
listc = [int(x) for x in input().split()]
lista = [int(x) for x in input().split()]
n = first[0]
m = first[1]
walletIndex = 0
maxGames = 0
for game in range(n):
	if walletIndex < m and lista[walletIndex] >= listc[game]:
		walletIndex += 1
		maxGames += 1
print(maxGames)


R = lambda : map(int, input().split())
(n, m) = R()
C = list(R())
A = list(R())
ans = 0
j = 0
for c in C:
	if j < m and c <= A[j]:
		ans += 1
		j += 1
print(ans)


(n, m) = list(map(int, input().split()))
g = list(map(int, input().split()))
b = list(map(int, input().split()))
p = 0
l = 0
for k in range(n):
	if b[l] >= g[k]:
		if l < m - 1:
			p += 1
			l += 1
		else:
			l += 1
			p += 1
			break
	else:
		pass
print(p)


X = list(map(int, input().split(' ')))
Games = list(map(int, input().split(' ')))
Bills = list(map(int, input().split(' ')))
Size = 0
index = 0
for i in Games:
	if index < X[1]:
		if Bills[index] >= i:
			index += 1
			Size += 1
print(str(Size))


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
m = list(map(int, input().split()))
i = 0
j = 0
c = 0
while i < n and j < k:
	if m[j] >= l[i]:
		i += 1
		j += 1
		c += 1
	else:
		i += 1
print(c)


from sys import stdin, stdout
(n, m) = [int(x) for x in stdin.readline().split(' ')]
costs = [int(x) for x in stdin.readline().split(' ')]
nominals = [int(x) for x in stdin.readline().split(' ')]
bought = 0
for i in range(n):
	if len(nominals) == 0:
		break
	if nominals[0] >= costs[i]:
		bought += 1
		nominals = nominals[1:]
stdout.write(str(bought))


(n, m) = map(int, input().split())
g = [int(x) for x in input().split()]
b = [int(y) for y in input().split()]
cnt = 0
index = 0
for x in g:
	if b[index] >= x:
		cnt += 1
		index += 1
		if index == m:
			break
print(cnt)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
total = 0
while a and c:
	if a[0] >= c[0]:
		total += 1
		a.pop(0)
		c.pop(0)
	else:
		c.pop(0)
print(total)


(n, m) = map(int, input().split())
c = [int(i) for i in input().split()]
a = [int(j) for j in input().split()]
count = 0
game = 0
bill = 0
while bill < m and game < n:
	if a[bill] >= c[game]:
		count += 1
		bill += 1
	game += 1
print(count)


(n, m) = map(int, input().split())
cost = list(map(int, input().split()))
wallet = list(map(int, input().split()))
count = 0
length = list([len(cost), len(wallet)])
length.sort()
for i in range(length[1]):
	try:
		if wallet[0] >= cost[0]:
			count += 1
			wallet.pop(0)
			cost.pop(0)
			continue
		else:
			cost.pop(0)
	except IndexError:
		print(count)
		exit()
print(count)


(n, m) = map(int, input().split())
(c, a) = (list(map(int, input().split())), list(map(int, input().split())))
v = 0
for ci in c:
	if a and ci <= a[0]:
		a.pop(0)
		v += 1
print(v)


(m, n) = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
counter = 0
i = j = 0
while True:
	if a[j] >= c[i]:
		counter += 1
		j += 1
		i += 1
	else:
		i += 1
	if i >= len(c) or j >= len(a):
		break
print(counter)


(games, bills) = [int(x) for x in input().split(' ')]
arr = [int(x) for x in input().split(' ')]
bi = [int(x) for x in input().split(' ')]
i = 0
index = 0
total = 0
j = 0
while i < bills:
	while index < games and arr[index] > bi[i]:
		index += 1
	if index < games:
		total += 1
		index += 1
		i += 1
	else:
		break
print(total)


a = lambda : map(int, input().split())
(n, m) = a()
l = list(a())
d = list(a())
c = 0
j = 0
for i in l:
	if j < m and i <= d[j]:
		c += 1
		j += 1
print(c)


(m, n) = map(int, input().split(' '))
costs = list(map(int, input().split(' ')))
money = list(map(int, input().split(' ')))
bought = 0
curr_game = 0
while curr_game < m and bought < n:
	if costs[curr_game] <= money[bought]:
		curr_game += 1
		bought += 1
	else:
		curr_game += 1
print(bought)


import sys
lines = []
for Line in sys.stdin:
	lines.append(Line.rstrip('\n'))
(n, m) = list(map(int, lines[0].split()))
del lines[0]
c = list(map(int, lines[0].split()))
del lines[0]
a = list(map(int, lines[0].split()))
del lines[0]
i = 0
j = 0
while i < len(a) and j < len(c):
	if a[i] >= c[j]:
		i += 1
	j += 1
print(i)


def count(a, c):
	num = 0
	while len(c) != 0 and len(a) != 0:
		if a[0] >= c[0]:
			a.pop(0)
			c.pop(0)
			num += 1
		else:
			c.pop(0)
	return num
(n, m) = input().split()
c = list(input().split())
a = list(input().split())
for i in range(len(c)):
	c[i] = int(c[i])
for i in range(len(a)):
	a[i] = int(a[i])
print(count(a, c))


(n, q) = map(int, input().split())
costs = [int(c) for c in input().split()]
bills = [int(b) for b in input().split()]
i = 0
j = 0
count = 0
while i < len(costs) and j < len(bills):
	if bills[j] >= costs[i]:
		j += 1
		i += 1
		count += 1
	else:
		i += 1
print(count)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
count = 0
for i in a:
	l = len(c)
	for j in range(l):
		if i >= c[0]:
			count += 1
			c.pop(0)
			break
		else:
			c.pop(0)
print(count)


(n, m) = map(int, input().split())
games = list(map(int, input().split()))
cup = list(map(int, input().split()))
i = 0
for game in games:
	if cup[i] >= game:
		i += 1
	if i == m:
		break
print(i)


(n, m) = map(int, input().split())
S = list(map(int, input().split()))
W = list(map(int, input().split()))
count = 0
j = 0
i = 0
while j < len(S):
	while i < len(W):
		if S[j] <= W[i]:
			count += 1
			i += 1
		j += 1
		if j == len(S) or i == len(W):
			print(count)
			exit()
print(count)


(n, m) = map(int, input().split())
c = [int(num) for num in input().split()]
a = [int(num) for num in input().split()]
ans = 0
for i in c:
	for j in a:
		if i <= j:
			ans = ans + 1
			a.remove(j)
		break
print(ans)


def Jueguitos(games, bills):
	cont = 0
	for g in range(len(games)):
		if len(bills) != 0:
			if bills[0] >= games[g]:
				cont += 1
				bills.pop(0)
	return cont
(n, m) = [int(x) for x in input().split()]
gamesNumbers = input()
billNumbers = input()
games = [int(i) for i in gamesNumbers.split(' ')]
bills = [int(i) for i in billNumbers.split(' ')]
print(Jueguitos(games, bills))


(a, b) = map(int, input().split())
ar = list(map(int, input().split()))
br = list(map(int, input().split()))
rez = 0
j = 0
for i in br:
	flag = 1
	while j != a:
		if i >= ar[j]:
			rez += 1
			flag = 0
			j += 1
			break
		j += 1
	if flag:
		break
print(rez)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
k = list(map(int, input().split()))
x = 0
y = 0
count = 0
for i in range(n):
	if x >= m:
		break
	elif c[i] <= k[x]:
		x += 1
		count += 1
print(count)


def solve(N, M, C, A):
	i = 0
	for c in C:
		if i == M or A[i] < c:
			continue
		i += 1
	return i

def main():
	(N, M) = [int(e) for e in input().split(' ')]
	C = [int(e) for e in input().split(' ')]
	A = [int(e) for e in input().split(' ')]
	assert len(C) == N
	assert len(A) == M
	print(solve(N, M, C, A))
main()


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
e = list(map(int, input().split()))
d = []
for i in e:
	if i != 0:
		d.append(i)
k = 0
for i in c:
	if k < b:
		if d[k] >= i:
			k += 1
print(k)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
c = 0
w = 0
for i in range(n):
	if c < k and p[i] <= q[c]:
		c += 1
		w += 1
print(w)


(res, _) = (0, input())
n = [int(x) for x in input().split()]
m = [int(x) for x in input().split()]
for row in n:
	if res >= len(m):
		break
	if row <= m[res]:
		res += 1
print(res)


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
(a, b) = (list(map(int, stdin.readline().split())), list(map(int, stdin.readline().split())))
(cnt, ans) = (0, 0)
for x in a:
	if b[cnt] >= x:
		ans += 1
		cnt += 1
	if cnt == len(b):
		break
print(ans)


(n, m) = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
j = 0
for i in range(n):
	if arr1[i] <= arr2[j]:
		j += 1
	if j == m:
		break
print(j)


billPos = 0
gamePos = 0
numGames = 0
nm = [int(s) for s in input().split(' ')]
n = nm[0]
m = nm[1]
costs = [int(s) for s in input().split(' ')]
bills = [int(s) for s in input().split(' ')]
for i in costs:
	if billPos > m - 1:
		break
	elif bills[billPos] >= costs[gamePos]:
		billPos += 1
		gamePos += 1
		numGames += 1
	else:
		gamePos += 1
print(numGames)


from sys import stdin, stdout
from collections import deque
(n, m) = map(int, stdin.readline().split())
c = list(map(int, stdin.readline().split()))
a = deque(map(int, stdin.readline().split()))
count = 0
for i in range(n):
	if len(a) != 0 and c[i] <= a[0]:
		count += 1
		del a[0]
	elif len(a) != 0 and c[i] > a[0]:
		continue
stdout.write('%i' % count)


basura = input()
games = input().split(' ')
for i in range(len(games)):
	games[i] = int(games[i])
bills = input().split(' ')
for i in range(len(bills)):
	bills[i] = int(bills[i])
i = 0
j = 0
count = 0
while j < len(games) and i < len(bills):
	if bills[i] >= games[j]:
		i += 1
		count -= -1
		j += 1
	else:
		j += 1
print(count)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
counter = 0
for cost in c:
	if a == []:
		break
	if a[0] >= cost:
		counter += 1
		del a[0]
print(counter)


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
sd = list(map(int, input().split()))
j = 0
ans = 0
for i in range(n):
	if j < m:
		if sd[j] >= s[i]:
			j += 1
			ans += 1
print(ans)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
(j, l, i) = (0, 0, 0)
while len(a) > 0:
	if a[i] >= c[j]:
		l += 1
		j += 1
		del a[i]
	else:
		j += 1
	if j == len(c):
		break
print(l)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
p = 0
ans = 0
for x in a:
	if p >= m:
		break
	if b[p] >= x:
		ans += 1
		p += 1
print(ans)


(b, d) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
k = len(a)
n = 0
while k > 0 and len(a) > 0 and (len(c) > 0):
	if a[0] >= c[0]:
		del a[0]
		del c[0]
		n += 1
		k -= 1
	else:
		del c[0]
print(n)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
l = 0
r = 0
while l < n and r < m:
	if c[l] <= a[r]:
		ans += 1
		l += 1
		r += 1
	else:
		l += 1
print(ans)


(n, m) = [int(x) for x in input().split()]
games = [int(x) for x in input().split()]
nominals = [int(x) for x in input().split()]
c = 0
for i in range(n):
	if c == len(nominals):
		break
	if nominals[c] >= games[i]:
		c += 1
print(c)


while True:
	try:

		def soln(n, m):
			gif = list(map(int, input().split()))
			walt = list(map(int, input().split()))
			i = 0
			j = 0
			buy = 0
			while i < n:
				if j == m:
					break
				if gif[i] <= walt[j]:
					buy += 1
					j += 1
				i += 1
			print(buy)

		def read():
			(n, m) = map(int, input().split())
			soln(n, m)
		if __name__ == '__main__':
			read()
	except EOFError:
		break


(N, M) = map(int, input().split())
n = list(map(int, input().split()))
m = list(map(int, input().split()))
count = 0
for i in n:
	if len(m) == 0:
		break
	if m[0] >= i:
		count += 1
		m.pop(0)
print(count)


(n, m) = map(int, input().split())
N = list(map(int, input().split()))
M = list(map(int, input().split()))
p = 0
for i in N:
	p += p < len(M) and M[p] >= i
print(p)


(n, m) = map(int, input().split())
pls = list(map(int, input().split()))
bls = list(map(int, input().split()))
ans = 0
j = 0
for i in range(n):
	if pls[i] <= bls[j]:
		ans += 1
		j += 1
		if j == m:
			break
print(ans)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
i = totPurch = 0
while i < n and len(a) > 0:
	if a[0] >= c[i]:
		totPurch += 1
		a.pop(0)
	i += 1
print(totPurch)


(n, m) = [int(__) for __ in input().strip().split()]
c = [int(__) for __ in input().strip().split()]
a = [int(__) for __ in input().strip().split()]
ans = 0
(ci, ai) = (0, 0)
while ci < n and ai < m:
	if a[ai] >= c[ci]:
		ai += 1
		ci += 1
		ans += 1
	else:
		ci += 1
print(ans)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
bill = 0
ans = 0
for i in range(len(c)):
	if bill < len(a) and c[i] <= a[bill]:
		ans += 1
		bill += 1
print(ans)


(n, m) = list((int(x) for x in input().split(' ')))
a = list((int(x) for x in input().split(' ')))
c = list((int(x) for x in input().split(' ')))
cc = []
ans = 0
p = len(c)
q = len(a)
k = m = n = 0
for i in range(m, p):
	for j in range(n, q):
		if c[i] >= a[j]:
			m = i + 1
			n = j + 1
			ans = ans + 1
			k = k + 1
			break
	if k == 0:
		break
	k = 0
print(ans)


def scanf(obj=list, type=int):
	return obj(map(type, input().split()))
(n1, n2) = scanf()
(m1, m2) = (scanf(), scanf())
ans = j = 0
for i in range(n1):
	if j == n2:
		break
	if m1[i] <= m2[j]:
		ans += 1
		j += 1
print(ans)


import sys
from array import array

def readline():
	return sys.stdin.buffer.readline().decode('utf-8')
(n, m) = map(int, readline().split())
c = list(map(int, readline().split()))
a = list(map(int, readline().split()))
(i, ans) = (0, 0)
for bill in a:
	while i < n and bill < c[i]:
		i += 1
	if i < n:
		ans += 1
		i += 1
print(ans)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
p = list(map(int, input().split()))
c = 0
for i in l:
	if len(p) == 0:
		break
	if p[0] >= i:
		c += 1
		p.remove(p[0])
print(c)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l1 = list(map(int, input().split()))
c = 0
for i in range(n):
	if len(l1) == 0:
		break
	if l1[0] >= l[i]:
		c += 1
		l1.pop(0)
print(c)


input()
I = lambda : [*map(int, input().split())]
(a, b) = (I(), I())
print(sum((1 for x in a if len(b) > 0 and b[0] >= x and b.pop(0))))


(n, m) = [int(elem) for elem in input().split(' ')]
c = [int(elem) for elem in input().split(' ')]
a = [int(elem) for elem in input().split(' ')]
(position, count) = (0, 0)
for i in c:
	if i <= a[position]:
		count += 1
		if position == len(a) - 1:
			break
		position += 1
print(count)


input()
c = map(int, input().split())
a = map(int, input().split())
r = 0
for x in a:
	for y in c:
		if y <= x:
			r += 1
			break
print(r)


st = input()
n = int(st.split()[0])
m = int(st.split()[1])
c = []
a = []
st = input()
for i in range(n):
	c.append(int(st.split()[i]))
st = input()
for i in range(m):
	a.append(int(st.split()[i]))
s = 0
for i in range(n):
	if c[i] <= a[0]:
		s += 1
		if len(a) != 0:
			a.pop(0)
			if len(a) == 0:
				a.append(0)
		else:
			a.append(0)
print(s)


(n, m) = map(int, input().split(' '))
prices = list(map(int, input().split(' ')))
money = list(map(int, input().split(' ')))
i = 0
j = 0
ans = 0
while i < n and j < m:
	if money[j] >= prices[i]:
		ans += 1
		i += 1
		j += 1
	else:
		i += 1
print(ans)


(n, m) = input().split()
n = int(n)
m = int(m)
games = []
wallet = []
for i in input().split():
	games.append(int(i))
for i in input().split():
	wallet.append(int(i))
counter = 0
for i in games:
	for a in wallet:
		if a < i:
			break
		else:
			counter += 1
			wallet.remove(a)
			break
print(counter)


from array import array
from sys import stdin
import bisect
from bisect import *
import itertools
from itertools import *

def scan_gen():
	for line in stdin:
		yield from iter(line.split())
scan = scan_gen()

def nint():
	return int(next(scan))

def nintk(k):
	return tuple((nint() for _ in range(k)))

def nfloat():
	return float(next(scan))

def intar_init(size):
	return array('i', [0]) * size

def intar(size=None):
	if size == None:
		size = nint()
	arr = intar_init(size)
	for x in range(size):
		arr[x] = nint()
	return arr

def solve():
	(n, m) = nintk(2)
	C = intar(n)
	A = intar(m)
	ci = 0
	res = 0
	for m in A:
		while ci < n and C[ci] > m:
			ci += 1
		if ci == n:
			break
		ci += 1
		res += 1
	print(res)
solve()


import re

def main():
	(total_games, total_notes) = map(int, input().split())
	games = [int(i) for i in input().split()]
	notes = [int(i) for i in input().split()]
	note = 0
	for game in games:
		if notes[note] >= game:
			note += 1
		if note == total_notes:
			break
	print(note)
main()


(game_num, bill_num) = map(int, input().split())
game = list(map(int, input().split()))
bill = list(map(int, input().split()))
count = 0
for i in range(0, game_num):
	if bill[0] >= game[0]:
		game.pop(0)
		bill.pop(0)
		count = count + 1
		if len(bill) == 0:
			break
	else:
		game.pop(0)
print(count)


(a, b) = input().split()
(a, b) = (int(a), int(b))
c = input().split()
v = input().split()
k = 0
for i in range(a):
	if len(v) > 0:
		if int(c[i]) <= int(v[0]):
			k += 1
			v.pop(0)
	else:
		break
print(k)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
answer = 0
index = 0
for i in range(n):
	if index >= m:
		break
	elif c[i] <= a[index]:
		answer += 1
		index += 1
print(answer)


import time
(n, m) = (int(i) for i in input().split())
c = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
start = time.time()
a.append(0)
ans = 0
for j in range(n):
	if c[j] <= a[ans]:
		ans += 1
print(ans)
finish = time.time()


(n, m) = map(int, input().split())
l1 = [*map(int, input().split())]
l2 = [*map(int, input().split())]
c = 0
ind1 = ind2 = 0
while ind1 != n and ind2 != m:
	if l2[ind2] >= l1[ind1]:
		c += 1
		ind1 += 1
		ind2 += 1
	else:
		ind1 += 1
print(c)


(l, k) = list(map(int, input().split()))
p = list(map(int, input().split()))
pp = list(map(int, input().split()))
y = 0
c = 0
tp = 0
t = len(pp)
for x in range(555555):
	if y <= len(pp) - 1 and tp <= len(p) - 1:
		if pp[y] >= p[tp]:
			y += 1
			tp += 1
		else:
			tp += 1
	else:
		print(y)
		break


(n, m) = map(int, input().split())
game = list(map(int, input().split()))
bill = list(map(int, input().split()))
cnt = 0
j = 0
for i in range(n):
	if game[i] <= bill[j]:
		cnt += 1
		j += 1
	if j == m:
		break
print(cnt)


nk = input().split()
n = int(nk[0])
k = int(nk[1])
c = list(map(int, input().rstrip().split()))
a = list(map(int, input().rstrip().split()))
count = 0
while len(a) > 0 and len(c) > 0:
	if a[0] >= c[0]:
		del a[0]
		del c[0]
		count = count + 1
	else:
		del c[0]
print(count)


(a, b) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
c = 0
d = 0
e = 0
while c < len(x) and d < len(y):
	if x[c] <= y[d]:
		e += 1
		d += 1
	c += 1
print(e)


(n, m) = map(int, input().split())
games = list(map(int, input().split()))
wallet = list(map(int, input().split()))
count = i = k = 0
while i < m:
	p = False
	for j in range(k, n):
		if wallet[i] >= games[j]:
			count += 1
			i += 1
			k = j + 1
			p = True
			break
	if p == False:
		break
	if k > n - 1:
		break
print(count)


(n, m) = [int(v) for v in input().split()]
c = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]
ans = 0
apos = 0
for ci in c:
	if ci <= a[apos]:
		ans += 1
		apos += 1
	if apos >= len(a):
		break
print(ans)


(n, m) = list(map(int, input().split()))
c = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(n):
	if len(a) == 0 or len(c) == 0:
		break
	if a[0] >= c[0]:
		a.pop(0)
		c.pop(0)
		continue
	c.pop(0)
print(str(m - len(a)))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
k = 0
for elem in c:
	if a[k] >= elem:
		k += 1
	if k == m:
		break
print(k)


a = [int(q) for q in input().strip().split()]
b = [int(q) for q in input().strip().split()]
c = [int(q) for q in input().strip().split()]
ct = 0
while len(b) > 0 and len(c) > 0:
	if b[0] <= c[0]:
		c.remove(c[0])
		ct += 1
	b.remove(b[0])
print(ct)


(no_of_games, no_of_bills) = map(int, input().split())
games = list(map(int, input().split()))
bills = list(map(int, input().split()))
(game, bill, buy) = (0, 0, 0)
for g in games:
	if bill < no_of_bills and bills[bill] >= g:
		bill += 1
		buy += 1
print(buy)


(n, m) = map(int, input().split())
game = list(map(int, input().split()))
money = list(map(int, input().split()))
i = 0
c = 0
for t in money:
	for q in range(i, n):
		if game[q] <= t:
			i += 1
			c += 1
			break
		i += 1
	if q == n - 1:
		break
print(c)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
j = 0
k = 0
for i in range(n):
	if j < m and b[j] >= a[i]:
		k += 1
		j += 1
print(k)


(n, m) = [int(x) for x in input().strip().split()]
c = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
ans = 0
ai = 0
for ci in c:
	if ai < len(a) and a[ai] >= ci:
		ai += 1
		ans += 1
print(ans)


import sys
from collections import defaultdict
import math
lines = [line.strip() for line in sys.stdin.readlines()]
(n, m) = map(int, lines[0].split(' '))
c = map(int, lines[1].split(' '))
a = list(map(int, lines[2].split(' ')))
current = a[0]
del a[0]
count = 0
for game in c:
	if game <= current:
		if not a:
			current = -420
		else:
			current = a[0]
			del a[0]
		count += 1
print(count)


import sys
import math

class Reader:

	def __init__(self):
		self.data = ''.join(sys.stdin.readlines()).split()
		self.idp = 0

	def get(self, t):
		value = t(self.data[self.idp])
		self.idp += 1
		return value

	def list(self, t, k):
		value = map(t, self.data[self.idp:self.idp + k])
		self.idp += k
		return list(value)
r = Reader()
(n, m) = (r.get(int), r.get(int))
c = r.list(int, n)
a = r.list(int, m)
(i, j) = (0, 0)
k = 0
while i < n and j < m:
	if c[i] <= a[j]:
		j += 1
		k += 1
	i += 1
print(k)


from collections import deque
(n, m) = map(int, input().split())
x = deque(map(int, input().split()))
y = deque(map(int, input().split()))
ans = 0
while 1:
	if not x or not y:
		break
	if y[0] >= x[0]:
		ans += 1
		y.popleft()
	x.popleft()
print(ans)


(n, m) = [int(e) for e in input().split(' ')]
c = [int(e) for e in input().split(' ')]
a = [int(e) for e in input().split(' ')]
cursor = 0
for k in range(n):
	if c[k] <= a[cursor]:
		cursor += 1
	if cursor == m:
		break
print(cursor)


def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	num = 0
	for i in range(n):
		if a[i] <= b[num]:
			num += 1
			if num == m:
				break
	print(num)
solve()


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
k = list(map(int, input().split()))
ans = 0
while len(l) > 0 and len(k) > 0:
	if l[0] <= k[0]:
		ans += 1
		del l[0]
		del k[0]
	else:
		del l[0]
print(ans)


def gameshopping(c, a):
	i = 0
	count = 0
	while i < len(c) and len(a) > 0:
		cost = c[i]
		bill = a[0]
		if cost <= bill:
			a.pop(0)
			count = count + 1
		i = i + 1
	return count
(n1, n2) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
print(gameshopping(c, a))


(n, m) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
count = 0
for game in c:
	if len(a) > 0:
		curr_b = a[0]
		if curr_b >= game:
			count += 1
			a = a[1:]
print(count)


from sys import stdin, stdout
from collections import deque

def main():
	_ = stdin.readline()
	costo_juegos = (int(n) for n in stdin.readline().split())
	billetera = deque([int(n) for n in stdin.readline().split()])
	cont = 0
	while billetera:
		try:
			if billetera[0] >= costo_juegos.__next__():
				billetera.popleft()
				cont += 1
		except StopIteration:
			break
	stdout.write('%d\n' % cont)
main()


R = lambda : map(int, input().split())
R()
(c, a) = (R(), [*R()] + [0])
i = 0
for x in c:
	i += x <= a[i]
print(i)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
for i in c:
	try:
		if i <= a[0]:
			ans += 1
			a.pop(0)
	except:
		continue
print(ans)


def MAIN():
	(n, m) = map(int, input().split())
	game = input().split()
	wallet = input().split()
	game = [int(a) for a in game]
	wallet = [int(a) for a in wallet]
	count = 0
	for i in range(len(game)):
		if len(wallet) and game[i] <= wallet[0]:
			wallet = wallet[1:]
			count += 1
	print(count)
MAIN()


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
c = c[::-1]
a = a[::-1]
cnt = 0
while c and a:
	x = c.pop()
	if x <= a[-1]:
		cnt += 1
		a.pop()
print(cnt)


def main():
	(n, m) = map(int, input().split())
	c = list(map(int, input().split()))
	a = list(map(int, input().split()))
	i = j = 0
	while i < n and j < m:
		if c[i] <= a[j]:
			j += 1
		i += 1
	print(j)
main()


(a, b) = map(int, input().split())
arr1 = list(map(int, input().split()))[::-1]
arr2 = list(map(int, input().split()))[::-1]
bought = 0
while arr1 and arr2:
	buy = arr1.pop()
	if arr2[-1] >= buy:
		bought += 1
		arr2.pop()
print(bought)


(n, m) = map(int, input().split())
costs = list(map(int, input().split()))
bills = list(map(int, input().split()))
pos = 0
cnt = 0
for i in range(n):
	if bills[pos] >= costs[i]:
		pos += 1
		cnt += 1
	if pos == m:
		break
print(cnt)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = list(map(int, input().split()))
buy = 0
k = 0
for i in range(n):
	if k == m:
		break
	if a[k] >= c[i]:
		k += 1
		buy += 1
print(buy)


(kol_game, kol_pap) = map(int, input().split())
price_game = list(map(int, input().split()))
nom_pap = list(map(int, input().split()))
if min(nom_pap) < min(price_game):
	print(0)
else:
	(i, s, new_j) = (0, 0, 0)
	while i < kol_game:
		j = new_j
		while j < kol_pap:
			if nom_pap[j] >= price_game[i]:
				s += 1
				new_j += 1
				j = kol_pap
			else:
				j = kol_pap
		i += 1
	print(s)


x = [int(i) for i in input().split()]
(n, m) = (x[0], x[1])
nlist = [int(i) for i in input().split()]
mlist = [int(i) for i in input().split()]
index = 0
i = 0
res = 0
while i < n and index < m:
	if nlist[i] <= mlist[index]:
		res = res + 1
		i = i + 1
		index = index + 1
	else:
		i = i + 1
print(res)