After lessons Nastya decided to read a book. The book contains $n$ chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.

Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number $k$ as the first page which was not read (i.e. she read all pages from the $1$-st to the $(k-1)$-th).

The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).


-----Input-----

The first line contains a single integer $n$ ($1 \leq n \leq 100$) — the number of chapters in the book.

There are $n$ lines then. The $i$-th of these lines contains two integers $l_i$, $r_i$ separated by space ($l_1 = 1$, $l_i \leq r_i$) — numbers of the first and the last pages of the $i$-th chapter. It's guaranteed that $l_{i+1} = r_i + 1$ for all $1 \leq i \leq n-1$, and also that every chapter contains at most $100$ pages.

The $(n+2)$-th line contains a single integer $k$ ($1 \leq k \leq r_n$) — the index of the marked page. 


-----Output-----

Print a single integer — the number of chapters which has not been completely read so far.


-----Examples-----
Input
3
1 3
4 7
8 11
2

Output
3

Input
3
1 4
5 9
10 12
9

Output
2

Input
1
1 7
4

Output
1



-----Note-----

In the first example the book contains $11$ pages and $3$ chapters — $[1;3]$, $[4;7]$ and $[8;11]$. Nastya marked the $2$-nd page, so she finished in the middle of the $1$-st chapter. So, all chapters has not been read so far, so the answer is $3$.

The book in the second example contains $12$ pages and $3$ chapters too, but Nastya finished reading in the middle of the $2$-nd chapter, so that the answer is $2$.

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
lis = []
n = int(input())
for chap in range(n):
	(x, y) = map(int, input().split())
	lis.append((x, y))
page = int(input())
for (x, y) in lis:
	if page >= x and page <= y:
		ind = lis.index((x, y))
print(n - ind)


I = input
a = [int(I().split()[1]) for _ in [0] * int(I())]
k = int(I())
print(sum((x >= k for x in a)))


n = int(input())
a = []
for i in range(n):
	(x, y) = list(map(int, input().split()))
	z = [i for i in range(x, y + 1)]
	a.append(z)
k = int(input())
for i in range(n):
	if k in a[i]:
		c = i
		break
print(n - c)


n = int(input())
b = []
a = 0
for i in range(n):
	(l, r) = map(int, input().split())
	b.append(r)
k = int(input())
for i in range(len(b)):
	if k <= b[i]:
		a = i
		break
print(n - a)


params = []
params.append(int(input()))
for i in range(1, params[0] + 1):
	params.append(input().split(' '))
	for j in range(0, 2):
		params[i][j] = int(params[i][j])
params.append(int(input()))
mark = params[params[0] + 1]
for i in range(1, params[0] + 1):
	if mark in range(params[i][0], params[i][1] + 1):
		print(params[0] - i + 1)
		break


n = int(input())
b = []
for i in range(n):
	(tl, tr) = list(map(int, input().split()))
	b.append((tl, tr))
k = int(input())
ans = 0
for (l, r) in b:
	if k <= r:
		ans += 1
print(ans)


n = input()
n = int(n)
a = []
for i in range(n):
	(f, l) = input().split()
	f = int(f)
	l = int(l)
	a.append(f)
	a.append(l)
k = input()
k = int(k)
ans = 0
for i in range(0, len(a) - 1, 2):
	if a[i] <= k and a[i + 1] >= k:
		ans = ans + 1
	elif a[i] > k:
		ans = ans + 1
print(ans)


f = int(input())
l = []
count = 0
z = f
while z > 0:
	(a, b) = map(int, input().split())
	l.append(a)
	l.append(b)
	z -= 1
c = int(input())
e = f * 2 - 2
while e >= 0:
	if c >= l[e]:
		print(count + 1)
		break
	else:
		e -= 2
		count += 1


total_chp = int(input())

def countPages(start_page, end_page):
	return list(range(start_page, end_page + 1))
chp = []
for i in range(total_chp):
	(a, b) = map(int, input().split(' '))
	chp.append(countPages(a, b))
folded_page = int(input())
for i in chp:
	if folded_page in i:
		print(total_chp - chp.index(i))
		break


n = int(input())
l = []
for i in range(n):
	arr = tuple(map(int, input().split()))
	l.append(arr)
k = int(input())
j = 0
for i in range(len(l)):
	if k <= l[i][1]:
		j = j + 1
print(j)


n = input()
q = []
for i in range(int(n)):
	(a, b) = map(int, input().split())
	q.append(b)
k = int(input())
x = 0
for j in q:
	if j < k:
		x += 1
print(int(n) - x)


x = int(input().strip())
yo = []
p = x
for j in range(x):
	a = list(map(int, input().split(' ')))
	yo.append(a)
c = int(input().strip())
for i in yo:
	if c > i[1]:
		x -= 1
	elif i[0] <= c <= i[1]:
		print(x)
		break


n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
k = int(input())
for i in range(n):
	if k <= arr[i][1]:
		print(n - i)
		break


n = int(input())
a = [''] * n
for i in range(n):
	a[i] = input().split()
p = int(input())
for i in range(n):
	for j in range(2):
		if p >= int(a[i][0]) and p <= int(a[i][1]):
			c = i
print(n - c)


n = int(input())
k = 0
D = {}
l = r = 0
for i in range(n):
	lt = list(input().split())
	l = int(lt[0])
	r = int(lt[1])
	for j in range(l, r + 1):
		D[j] = k
	k += 1
q = int(input())
if q <= r:
	print(n - D[q])
else:
	print(0)


n = int(input())
a = []
for i in range(n):
	temp = list(map(int, input().split()))
	a.append(temp)
k = int(input())
for i in range(n):
	if k >= a[i][0] and a[i][1] >= k:
		ans = i
print(len(a) - ans)


num_chap = int(input())
my_list = []
for x in range(num_chap):
	temp = list(map(int, input().split()))
	my_list.append(temp)
marked_page = int(input())
for (x, y) in my_list:
	if marked_page > y:
		num_chap -= 1
		continue
	break
print(num_chap)


n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
k = int(input())
for i in range(n):
	if k <= l[i][1]:
		print(len(l) - i)
		exit()


n = int(input())
l = []
r = []
for _ in range(n):
	arr = list(map(int, input().split()))
	l.append(arr[0])
	r.append(arr[1])
k = int(input())
i = 0
while True:
	if r[i] >= k:
		print(len(r[i:]))
		break
	else:
		i += 1


n = int(input())
b = []
for i in range(n):
	b.append([int(x) for x in input().split()])
count = 0
c = int(input())
for i in b:
	if i[1] >= c and i[1] - i[0] <= 100:
		count += 1
print(count)


n = int(input())
chapters = []
for i in range(n):
	chapters.append(tuple(map(int, input().split())))
a = int(input())
for i in range(n):
	if chapters[i][0] <= a <= chapters[i][1]:
		print(n - i)
		break
else:
	print(0)


def next_chapters(n, book, page):
	for (i, (a, b)) in enumerate(book):
		if a <= page <= b:
			return n - i
	return 0
n = int(input())
book = []
for _ in range(n):
	(a, b) = map(int, input().split())
	book.append((a, b))
page = int(input())
print(next_chapters(n, book, page))


n = int(input())
array = []
for i in range(n + 1):
	hal = [int(i) for i in input().split()]
	array += [hal]
cari = array[len(array) - 1][0]
for i in range(n):
	if cari >= array[i][0] and cari <= array[i][1]:
		print(n - i)


n = int(input())
chapters = []
for i in range(n):
	(l, r) = map(int, input().split())
	chapters.append((l, r))
k = int(input())
read_chapter = 0
for i in range(n):
	if k >= chapters[i][0] and k <= chapters[i][1]:
		read_chapter = i
print(n - read_chapter)


def main():
	n = int(input())
	lr = [list(map(int, input().split())) for _ in range(n)]
	k = int(input())
	ret = 0
	for i in range(n):
		if lr[i][1] >= k:
			ret += 1
	print(ret)

def __starting_point():
	main()
__starting_point()


n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
x = int(input())
res = 0
for (u, v) in a[::-1]:
	if v >= x:
		res += 1
	else:
		break
print(res)


from array import *
data = array('i', [])
n = int(input())
b = n
for i in range(b):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	for j in range(x, y + 1):
		data.insert(len(data), n)
	n = n - 1
k = int(input())
print(data[k - 1])


n = int(input())
y = []
for i in range(n):
	(l, r) = map(int, input().split(' '))
	y.append((l, r))
k = int(input())
y = sorted(y)
i = count = 0
while i < len(y):
	if k > y[i][1]:
		count = count + 1
	else:
		break
	i = i + 1
print(len(y) - count)


n = int(input())
l = []
for i in range(n):
	t = input().split(' ')[0]
	l.append(int(t))
m = int(input())
for i in range(n - 1):
	if m < l[i + 1]:
		print(n - i)
		exit()
print('1')


n = int(input())
ln = []
for i in range(0, n):
	ln.append([int(j) for j in input().split(' ')])
m = int(input())
for i in range(0, n):
	if m <= ln[i][1]:
		f = i
		break
print(n - f)


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

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

def li():
	return list(mi())

def ceil(a, b):
	return (a + b - 1) // b
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
test = 0

def solve():
	n = ii()
	a = []
	for i in range(n):
		a.append(li())
	k = ii()
	ans = 0
	for i in range(n):
		if a[i][1] >= k:
			ans += 1
	print(ans)
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
t = 1
if test:
	t = ii()
for _ in range(t):
	solve()


t = int(input())
l = []
m = []
c = 0
for _ in range(t):
	(a, b) = map(int, input().split())
	l.append(a)
	m.append(b)
n = int(input())
for i in range(t):
	if n > l[i] and n > m[i]:
		c = c + 1
print(t - c)


n = int(input())
l = [] * n
r = [] * n
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(a)
	r.append(b)
k = int(input())
res = 0
for i in range(n):
	if k <= r[i]:
		res += 1
print(res)


n = int(input())
a = []
for x in range(n):
	a.append([int(num) for num in input().split()])
page = int(input())
rez = 0
for x in range(n):
	if a[x][1] < page:
		rez += 1
print(n - rez)


n = int(input())
result = []
for i in range(n):
	result.append(list(map(int, input().split())))
a = int(input())
ans = 0
for i in range(n):
	if a <= result[i][1] and a >= result[i][0]:
		count = i
		break
print(n - count)


n = int(input())
tot = []
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	tot.append((a, b))
k = int(input())
counter = 0
for item in tot:
	if item[0] <= k <= item[1]:
		print(n - counter)
		break
	counter += 1


n = int(input())
(s, e) = ([], [])
for _ in range(n):
	(x, y) = map(int, input().split())
	s.append(x)
	e.append(y)
p = int(input())
for i in range(n):
	if s[i] <= p <= e[i]:
		print(n - i)
		break


N = int(input())
pagei = [0]
for i in range(N):
	(l, r) = map(int, input().split())
	pagei.append(r)
K = int(input())
for i in range(1, N + 1):
	if pagei[i] >= K:
		ans = N - i + 1
		break
print(ans)


n = int(input())
(L, R) = ([], [])
for i in range(n):
	(l, r) = map(int, input().split())
	L.append(l)
	R.append(r)
k = int(input())
c = 0
for i in range(n):
	if L[i] <= k and R[i] <= r:
		c = 1
		continue
	if c != 0:
		c = c + 1
print(c)


n = int(input())
ch = []
for i in range(0, n):
	(a, b) = map(int, input().split())
	ch.append(a)
	ch.append(b)
k = int(input())
cnt = n << 1
for i in range(0, len(ch)):
	if k <= ch[i]:
		cnt = i
		break
print(n - cnt // 2)


n = int(input())
x = []
for i in range(n):
	(l, r) = map(int, input().split())
	x.append([l, r])
k = int(input())
ans = 0
for i in range(n):
	if x[i][0] <= k <= x[i][1]:
		print(n - ans)
		exit(0)
	ans += 1


n = int(input())
r = [[0] * 2] * n
for i in range(n):
	r[i] = list(map(int, input().split(' ')))
k = int(input())
for f in r:
	if k in range(f[0], f[1] + 1):
		break
	else:
		n -= 1
print(n)


n = int(input())
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	a.append(l)
	a.append(r)
k = int(input())
i = 0
while a[i] < k:
	i += 1
print(n - i // 2)


n = int(input())
finisedList = []
for i in range(n):
	(l, r) = map(int, input().split())
	finisedList.append(r)
k = int(input())
suma = n
for i in finisedList:
	if k <= i:
		break
	suma -= 1
print(suma)


n = int(input())
end = []
for i in range(n):
	temp = list(map(int, input().split(' ')))
	end.append(temp[1])
read = int(input())
total = 0
for i in end[::-1]:
	if read <= i:
		total += 1
	else:
		break
print(total)


n = input()
n = int(n)
arr = []
for i in range(n):
	arr += input().split()
arr = [int(i) for i in arr]
k = input()
k = int(k)
for i in range(1, 2 * n, 2):
	if k > arr[i]:
		n -= 1
print(n)


t = []
for i in range(int(input())):
	t.append(list(map(int, input().split())))
k = int(input())
for j in range(len(t)):
	if t[j][0] <= k <= t[j][1]:
		print(len(t) - j)
		break


ch = int(input())
listl = []
count = 0
for i in range(ch):
	pgn = list(map(int, input().split()))
	listl.append(pgn)
pgl = int(input())
for i in listl:
	(l, m) = (i[0], i[1] + 1)
	if pgl <= m:
		if pgl in range(l, m):
			break
print(ch - listl.index(i))


import math
n = int(input())
A = []
for i in range(n):
	a = list(map(int, input().split()))
	A.append(a[1])
m = int(input())
for i in range(n):
	if m <= A[i]:
		print(n - i)
		break


n = int(input())
arr = []
for _ in range(n):
	arr.append(list(map(int, input().split())))
k = int(input())
count = 0
for x in arr:
	if k <= x[1]:
		break
	count += 1
print(n - count)


x = int(input())
l = []
for j in range(x):
	(a, b) = map(int, input().split())
	l.append(a)
	l.append(b)
k = int(input())
for i in range(len(l)):
	if k <= l[i]:
		print(x - i // 2)
		break


a = int(input())
l = 0
a1 = []
for i in range(a):
	(d, b) = map(int, input().split())
	a1.append(b)
c = int(input())
for i in a1:
	if c > i:
		l += 1
print(a - l)


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)
isdebug = False
try:
	import pylint
	import numpy

	def dprint(*args, **kwargs):
		print(*args, file=sys.stderr)
	dprint('debug mode')
	isdebug = True
except Exception:

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

def red_inout():
	inId = 0
	outId = 0
	if not isdebug:
		inId = 0
		outId = 0
	if inId > 0:
		dprint('use input', inId)
		try:
			f = open('input' + str(inId) + '.txt', 'r')
			sys.stdin = f
		except Exception:
			dprint('invalid input file')
	if outId > 0:
		dprint('use output', outId)
		try:
			f = open('stdout' + str(outId) + '.txt', 'w')
			sys.stdout = f
		except Exception:
			dprint('invalid output file')
		atexit.register(lambda : sys.stdout.close())
if isdebug and len(sys.argv) == 1:
	red_inout()

def getIntList():
	return list(map(int, input().split()))

def solve():
	pass
T_ = 1
for iii_ in range(T_):
	(N,) = getIntList()
	zz = []
	for i in range(N):
		(l, r) = getIntList()
		zz.append((l, r))
	(x,) = getIntList()
	for i in range(N):
		(l, r) = zz[i]
		if l <= x <= r:
			print(N - i)
			break


from sys import stdin
L = stdin.read().rstrip().split('\n')
for i in range(1, len(L) - 1):
	if int(L[-1]) <= int(L[i].split()[1]):
		print(len(L) - 1 - i)
		exit()
print(0)


n = int(input())
q = []
for i in range(n):
	w = list(map(int, input().split()))
	q.append([i for i in range(w[0], w[1] + 1)])
k = int(input())
for i in q:
	f = 0
	for j in i:
		if j == k:
			f = 1
			break
	if f == 1:
		print(len(q) - q.index(i))


t = int(input())
b = []
count = 0
for a0 in range(t):
	x = list(map(int, input().split()))
	b.append(x)
n = int(input())
for i in range(0, len(b)):
	if n >= b[i][0] and n <= b[i][1]:
		count += len(b) - i
print(count)


n = int(input())
chapters = []
for i in range(n):
	chapters.append(list(map(int, input().split())))
page = int(input())
pas = 0
for e in chapters:
	if page > e[1]:
		pas += 1
	else:
		break
print(len(chapters) - pas)


c = int(input())
l = []
for i in range(c):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	l.append((a, b))
count = 0
index = int(input())
for i in range(c):
	if index >= l[i][0] and index <= l[i][1]:
		count = c - i
		i = c + 1
print(count)


n = int(input().strip())
s = 0
l = []
for i in range(n):
	a = tuple(map(int, input().strip().split()))
	l.append(a)
k = int(input().strip())
for i in range(n):
	if k <= l[i][1] and k >= l[i][0]:
		print(n - i)
		break


n = int(input())
(l, r) = ([], [])
for i in range(n):
	(L, R) = map(int, input().split())
	l.append(L)
	r.append(R)
k = int(input())
for i in range(n):
	if k <= r[i] and k >= l[i]:
		print(n - i)


n = int(input())
li = []
for _ in range(n):
	(x, y) = map(int, input().split())
	li.append((x, y))
k = int(input())
foo = 0
for i in range(n):
	(x, y) = (li[i][0], li[i][1])
	if k <= y and k >= x:
		foo = i
print(n - foo)


n = int(input())
book = []
for i in range(n):
	book.append(list(map(int, input().split())))
k = int(input())
for i in range(n):
	if book[i][0] <= k <= book[i][1]:
		print(n - i)


n = int(input())
h = [0] * n
m = [0] * n
for i in range(n):
	(h[i], m[i]) = map(int, input().split())
k = int(input())
for i in range(n):
	if k >= h[i] and k <= m[i]:
		g = i
		break
print(n - g)


n = int(input())
a = []
for i in range(n):
	m = [int(i) for i in input().split()]
	a.append(m)
x = int(input())
s = 0
for i in a:
	if x > i[1]:
		s += 1
print(n - s)


capitulos = int(input())
strPaginas = []
for i in range(capitulos):
	strPaginas.append(input())
pagMarcada = int(input())
capPorLeer = capitulos
for i in range(capitulos):
	listaCapitulos = strPaginas[i].split(' ')
	if int(listaCapitulos[0]) >= pagMarcada or int(listaCapitulos[1]) >= pagMarcada:
		break
	else:
		capPorLeer = capPorLeer - 1
print(capPorLeer)


n = int(input())
a = []
for i in range(n):
	a.append(tuple(map(int, input().split(' '))))
k = int(input())
s = 0
for x in a:
	if k > x[1]:
		s += 1
	else:
		break
print(n - s)


a = []
for i in range(int(input())):
	a.append(list(map(int, input().split())))
p = int(input())
for i in a:
	if i[1] >= p:
		print(len(a) - a.index(i))
		exit()


n = int(input())
lrs = [tuple(map(int, input().split())) for _ in range(n)]
k = int(input())
ch = n
for (l, r) in lrs:
	if k >= l and k <= r:
		print(ch)
		exit(0)
	ch -= 1
print(0)


N = int(input())
R = []
for _ in range(N):
	(l, r) = map(int, input().split())
	R.append(r)
k = int(input())
ans = 0
for i in range(N):
	if R[i] >= k:
		ans += 1
print(ans)


from sys import stdin

def main():
	inp = stdin
	n = int(inp.readline())
	pages = []
	for i in range(n):
		pages.append([int(x) for x in inp.readline().strip().split()])
	k = int(inp.readline())
	for i in range(len(pages)):
		if k >= pages[i][0] and k <= pages[i][1]:
			print(n - i)
			break
main()


n = int(input())
a = [[0] * 2 for i in range(n)]
for i in range(n):
	(a[i][0], a[i][1]) = map(int, input().split())
k = int(input())
ans = 0
for i in range(n):
	if k <= a[i][1]:
		ans = n - i
		break
print(ans)


n = int(input())
k = []
i = 0
while i < n:
	(x, y) = map(int, input().split())
	k += [y]
	i += 1
s = int(input())
x = 0
i = 0
while i < n:
	d = k[i]
	if s <= d:
		break
	i += 1
print(n - i)


n = int(input())
arr = []
for i in range(n):
	arr.append(list(map(int, input().split())))
k = int(input())
for i in range(n):
	if arr[i][0] >= k or k <= arr[i][1]:
		print(n - i)
		break


n = int(input())
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	a.append((l, r))
k = int(input())
for i in range(n):
	if k >= a[i][0] and k <= a[i][1]:
		print(n - i)
		exit()
print(0)


t = int(input())
pages = []
for i in range(t):
	(l, r) = map(int, input().split())
	pages.append(r)
k = int(input())
for i in pages:
	if k <= i:
		print(len(pages) - pages.index(i))
		break
	else:
		continue


(n, a) = (int(input()), [0])
for i in range(n):
	[s, e] = list(map(int, input().split(' ')))
	a += [i + 1] * (e - s + 1)
k = int(input())
print(n - a[k] + 1)


t = int(input())
l = []
while t:
	(n, m) = map(int, input().split())
	l.append([n, m])
	t -= 1
c = int(input())
for i in range(0, len(l)):
	if c >= l[i][0] and c <= l[i][1]:
		p = i
		break
print(len(l) - p)


n = int(input())
bookarr = []
for case in range(0, n):
	(l, r) = input().split()
	l = int(l)
	r = int(r)
	bookarr.append(l)
	bookarr.append(r)
k = int(input())
for i in bookarr:
	if k < i:
		res = len(bookarr) - bookarr.index(i)
		break
	elif k == i:
		res = len(bookarr) - bookarr.index(i)
		break
	else:
		res = 0
if res % 2 == 0:
	print(int(res / 2))
else:
	print(int((res + 1) / 2))


n = int(input())
l = []
r = []
for _ in range(n):
	(a, b) = map(int, input().split())
	l.append(a)
	r.append(b)
k = int(input())
chapter = 0
for i in range(len(l)):
	if l[i] <= k and r[i] >= k:
		chapter = i
print(n - chapter)


N = int(input())
Ns = [None] * (N + 1)
for i in range(1, N + 1):
	Ns[i] = int(input().split()[1])
Np = int(input())
wi = N
while wi and Ns[wi] >= Np:
	wi = wi - 1
print(N - wi)


n = int(input())
l = []
for i in range(n):
	(a, b) = list(map(int, input().split()))
	l.append([a, b])
k = int(input())
cnt = 0
for i in range(n):
	if l[i][1] < k:
		cnt += 1
print(n - cnt)


import math
li = []
for i in range(int(input())):
	(a, b) = map(int, input().split())
	li.append(a)
	li.append(b)
n = int(input())
count = sum([1 for i in range(len(li)) if li[i] >= n])
print(math.ceil(count / 2))


n = int(input())
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(a)
	l.append(b)
m = int(input())
for i in range(n * 2):
	if m <= l[i]:
		print(n - i // 2)
		break


b = []
n = int(input())
for i in range(n):
	b.append(list(map(int, input().split(' '))))
p = int(input())
for i in range(len(b)):
	if p <= b[i][1]:
		break
print(n - i)


n = int(input())
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	a.append(r)
a.append(1000000)
k = int(input())
for i in range(n):
	if a[i] >= k:
		print(n - i)
		break
else:
	print(0)


li = []
x = int(input())
for i in range(x):
	s = input().split()
	li.append(s)
n = int(input())
i = 0
j = 0
while i <= len(li) - 1:
	if int(li[i][1]) >= n:
		ans = i
		break
	i = i + 1
print(x - ans)


n = int(input())
A = []
for _ in range(n):
	(a, b) = map(int, input().split())
	A += [b - a + 1]
m = int(input())
m -= 1
for i in range(len(A)):
	if m < A[i]:
		print(n - i)
		break
	m -= A[i]
else:
	print(n)


n = int(input())
li = []
for i in range(n):
	(l, r) = map(int, input().split())
	li.append([l, r])
k = int(input())
fd = 0
fdc = []
for i in range(len(li)):
	if k > li[i][1]:
		fd = 1
		fdc.append(fd)
	else:
		fd = 0
		fdc.append(fd)
print(fdc.count(0))


chapter = int(input())
list1 = []
for i in range(chapter):
	(x, y) = (int(v) for v in input().split())
	list1.append(x)
	list1.append(y)
page = int(input())
j = 0
complete = 0
while j >= 0:
	if list1[2 * j] <= page and page <= list1[2 * j + 1]:
		print(chapter - complete)
		break
	else:
		j += 1
		complete += 1


def main():
	n = int(input())
	arr = []
	for i in range(n):
		(x, y) = map(int, input().split())
		arr.append(y)
	k = int(input())
	ans = 0
	for i in arr:
		if i >= k:
			ans += 1
	print(ans)
main()


def books(pages, k):
	ans = len(pages)
	for (i, j) in pages:
		if k in range(i, j + 1):
			return ans
		ans -= 1
	return 0
n = int(input())
arr = []
for i in range(n):
	x = list(map(int, input().rstrip().split()))
	arr.append(x)
k = int(input())
print(books(arr, k))


from bisect import bisect_right as br
n = int(input())
l = []
r = []
for i in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	r.append(y)
k = int(input())
x = br(l, k)
print(len(l) - x + 1)


numberofchapters = int(input())
endpoints = []
for i in range(numberofchapters):
	endpoints.append(int(input().split()[1]))
achieved = int(input())

def f(n, e, a):
	for i in range(n):
		if a < e[i]:
			return n - i
		elif a == e[i]:
			return n - i - 1
print(f(numberofchapters, endpoints, achieved - 1))


n = int(input())
arr = []
for i in range(n):
	(l, r) = map(int, input().split())
	arr.append([l, r])
k = int(input())
for i in range(n):
	(l, r) = arr[i]
	if l <= k <= r:
		print(n - i)
		exit()
print(n)


n = int(input())
arr = []
for i in range(n):
	(l, r) = map(int, input().split())
	arr.append([l, r])
k = int(input())
for i in range(n):
	l = arr[i][0]
	r = arr[i][1]
	if l <= k <= r:
		print(n - i)
		break


n = int(input())
a = []
for k in range(n):
	(i, j) = map(int, input().split())
	a.append((i, j))
k = int(input())
ans = 0
for i in range(n):
	if a[i][1] < k:
		ans += 1
print(n - ans)


t = int(input())
l = []
for i in range(t):
	(m, n) = map(int, input().split())
	l.append(n)
cnt = 0
x = int(input())
for i in l:
	if x > i:
		cnt += 1
print(t - cnt)


n = int(input())
l = []
r = []
for i in range(n):
	t = list(map(int, input().split(' ')))
	l.append(t[0])
	r.append(t[1])
k = int(input())
i = 0
while i < n:
	if k >= l[i] and k <= r[i]:
		break
	i = i + 1
c = len(l) - i
print(c)


n = int(input())
l = []
r = []
for _ in range(n):
	(x, y) = [int(s) for s in input().split()]
	l.append(x)
	r.append(y)
k = int(input())
glavs = 0
for i in range(n):
	if k >= l[i] and k <= r[i]:
		glavs = i
print(n - glavs)


n = int(input())
g = []
for i in range(n):
	g.append(list(map(int, input().split())))
k = int(input())
g.append([n + 1, n + 1])
i = 0
while k > g[i][1]:
	i += 1
print(n - i)


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


import time

def countChaptersLeft(bchapters, lastPage):
	chaptersLeft = 0
	chapterInx = 0
	for (inx, chapter) in enumerate(bchapters):
		if chapter[0] <= lastPage and lastPage <= chapter[1]:
			chapterInx = inx
	chaptersLeft = len(bchapters) - chapterInx
	return chaptersLeft

def solve():
	chapters = int(input())
	bchapters = []
	lastPage = 0
	for x in range(chapters):
		pageRang = [int(y) for y in input().split(' ')]
		bchapters.append(pageRang)
	lastPage = int(input())
	print(countChaptersLeft(bchapters, lastPage))
solve()


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
dgl = lambda : list(map(int, input()))
il = lambda : list(map(int, input().split()))
n = ii()
l = []
c = 0
sm = 0
for _ in range(n):
	l.append(list(f()))
k = ii()
for i in range(n):
	if l[i][0] <= k <= l[i][1]:
		sm = i + 1
	elif l[i][1] < k:
		c += 1
print(n - c)


import bisect

def solve(arr, k):
	a = [x[0] for x in arr]
	i = bisect.bisect(a, k)
	return len(arr) - i + 1

def main():
	n = int(input())
	arr = [list(map(int, input().split())) for t in range(n)]
	k = int(input())
	print(solve(arr, k))
main()


def solution(k, c):
	count = len(c)
	for i in range(0, len(c)):
		c1 = c[i][0]
		c2 = c[i][1] + 1
		pages = list(range(c1, c2))
		if k in pages:
			return count
			break
		count = count - 1

def main():
	n = int(input())
	c = []
	for i in range(0, n):
		chap = list(map(int, input().split()))
		c.append(chap)
	k = int(input())
	result = solution(k, c)
	print(result)
	return result
main()


n = int(input().strip())
book = [0]
for i in range(n):
	(start, end) = map(int, input().strip().split())
	for j in range(start, end + 1):
		book.append(i)
left_off = int(input().strip())
print(n - book[left_off])


n = int(input())
z = []
for i in range(n):
	z += (list(map(int, input().split())),)
k = int(input())
for i in range(n):
	if z[i][0] <= k <= z[i][1]:
		break
print(n - i)


l = []
n = int(input())
for i in range(n):
	(a, b) = map(int, input().strip().split())
	l.append((a, b))
page = int(input())
for i in range(n):
	if page <= l[i][1]:
		print(n - i)
		break


def chapters_left(ranges, k):
	chapters_read = 0
	for item in ranges:
		if k >= item[0] and k <= item[1]:
			return len(ranges) - chapters_read
		chapters_read += 1
	return len(ranges)
n = int(input())
ranges = []
for _ in range(n):
	ranges.append(list(map(int, input().split())))
k = int(input())
print(chapters_left(ranges, k))


a = int(input())
c = []
for i in range(a):
	c.append(input().split())
k = int(input())
for i in range(a):
	if k >= int(c[i][0]) and k <= int(c[i][1]):
		print(a - i)


def Book():
	n = int(input())
	chapter = []
	for i in range(n):
		(l, r) = list(map(int, input().split()))
		chapter.append(range(l, r + 1))
	k = int(input())
	for j in range(len(chapter)):
		if k in chapter[j]:
			print(len(chapter[j:]))
			return
Book()


R = lambda : map(int, input().split())
n = int(input())
L = []
for i in range(n):
	L.append(list(R()))
k = int(input())
i = 0
while i < n:
	if L[i][0] <= k <= L[i][1]:
		break
	i += 1
print(n - i)


n = int(input())
a = []
for i in range(n):
	b = [int(x) for x in input().split()]
	b[1] += 1
	a.append(b)
k = int(input())
for i in range(len(a)):
	x = a[i][0]
	y = a[i][1]
	if k in range(x, y):
		break
print(n - i)


n = int(input())
l = []
for i in range(n):
	(s, t) = input().split()
	l.append((int(s), int(t)))
d = int(input())
for (a, b) in l:
	if d > b:
		n -= 1
print(n)


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest, heapify, heappop, heappush, heapreplace
from math import ceil, floor, log, log2, sqrt, gcd, factorial, pow, pi
from bisect import bisect_left, bisect_right

def binNumber(n, size=4):
	return bin(n)[2:].zfill(size)

def iar():
	return list(map(int, input().split()))

def ini():
	return int(input())

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

def sti():
	return str(input())

def par(a):
	print(' '.join(list(map(str, a))))

def tdl(outerListSize, innerListSize, defaultValue=0):
	return [[defaultValue] * innerListSize for i in range(outerListSize)]

def sts(s):
	s = list(s)
	s.sort()
	return ''.join(s)

def bis(a, x):
	i = bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return [i, True]
	else:
		return [-1, False]

class pair:

	def __init__(self, f, s):
		self.fi = f
		self.se = s

	def __lt__(self, other):
		return (self.fi, self.se) < (other.fi, other.se)
n = ini()
l = []
r = []
for i in range(n):
	(x, y) = isp()
	l.append(x)
	r.append(y)
q = ini()
i = 0
while i < n:
	if q > r[i]:
		i += 1
		continue
	elif q == r[i]:
		break
	elif l[i] <= q and q < r[i]:
		break
print(n - i)


n = int(input())
pre = []
for i in range(n):
	(l, r) = map(int, input().split())
	pre.append(r)
from bisect import bisect_left as bl
k = int(input())
print(n - bl(pre, k))


n = int(input())
l = []
for io in range(n):
	m = [int(x) for x in input().split()]
	l.append(m[1])
x = int(input())
value = 0
for i in range(n):
	if l[i] >= x:
		value += 1
print(value)


n = int(input())
b = list()
for i in range(n):
	(f, l) = input().split(' ')
	(f, l) = (int(f), int(l))
	b.append((f, l))
c = int(input())
for (i, val) in enumerate(b):
	if c >= val[0] and c <= val[1]:
		print(len(b) - i)
		break


n = int(input())
l1 = []
l2 = []
for i in range(n):
	(l, r) = map(int, input().split())
	l1.append(l)
	l2.append(r)
k = int(input())
for (i, j) in zip(l1, l2):
	if i <= k and k <= j:
		print(n - l1.index(i))
		break


n = int(input())
l = []
c = 0
for i in range(n):
	l.append(list(map(int, input().split())))
k = int(input())
for i in range(len(l)):
	if k not in range(l[i][0], l[i][1] + 1) and k <= l[i][1]:
		c += 1
print(c + 1)


def main():
	n = int(input())
	chapters = [[int(x) for x in input().split()] for _ in range(n)]
	k = int(input())
	read_chapter = 0
	while k > chapters[read_chapter][1]:
		read_chapter += 1
	print(len(chapters) - read_chapter)
main()


x = int(input())
l = []
for i in range(1, x + 1):
	y = input().split()
	l.extend((int(y[1]) - int(y[0]) + 1) * [i])
z = int(input())
print(x + 1 - l[z - 1])


n = int(input())
s = []
for i in range(n):
	s.append([int(i) for i in input().split()])
k = int(input())
for i in range(n):
	if s[i][1] >= k:
		print(n - i)
		break


n = int(input())
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(a)
k = int(input())
count = 0
for i in l:
	if k >= i:
		count += 1
print(len(l) - count + 1)


n = int(input())
a = []
for i in range(n):
	(l, r) = list(map(int, input().split()))
	a.append(r)
k = int(input())
print(len([i for i in a if i >= k]))


n = int(input())
i = 0
left = []
right = []
while i < n:
	(l, r) = map(int, input().split())
	left.append(l)
	right.append(r)
	i += 1
k = int(input())
j = -1
for i in range(n):
	if k <= right[i]:
		j = i
		break
print(n - j)


n = int(input())
ans = 0
a = list()
for i in range(n):
	a.append(list(map(int, input().split())))
k = int(input())
i = 0
while k > a[i][1]:
	i += 1
print(n - i)


def main():
	n = int(input())
	l = []
	r = []
	for i in range(n):
		(x, y) = map(int, input().split(' '))
		l.append(x)
		r.append(y)
	k = int(input())
	counter = 0
	for i in range(n):
		if k > r[i]:
			counter += 1
	print(n - counter)
main()


n = int(input())
chapters = []
for i in range(0, n):
	(l, r) = (int(t) for t in input().split())
	obj = {'l': l, 'r': r}
	chapters.append(obj)
k = int(input())
for i in range(0, n):
	if k >= chapters[i]['l'] and k <= chapters[i]['r']:
		print(n - i)
		break


n = int(input())
chp = []
for i in range(n):
	chp.append(list(map(int, input().split())))
page = int(input())
i = 0
while chp[i][1] < page:
	i += 1
print(n - i)


import sys
amount = int(input())
array = []
for i in range(amount):
	array.append([int(s) for s in input().split()])
need = int(input())
for i in range(len(array)):
	if array[i][0] <= need and need <= array[i][1]:
		print(amount - i)
		sys.exit(0)


from sys import stdin
n = int(stdin.readline().strip())
s = []
for i in range(n):
	(a, b) = map(int, stdin.readline().strip().split())
	s.append([a, b])
k = int(stdin.readline().strip())
for i in range(n):
	if k <= s[i][1]:
		print(n - i)
		break


n = int(input())
arr = []
for i in range(n):
	(a, b) = list(map(int, input().split()))
	arr.append((a, b))
page = int(input())
ans = 0
for i in range(n):
	if arr[i][0] <= page <= arr[i][1]:
		ans = i
print(n - ans)


inp_chapter = int(input())
matrix = []
num = int()
for x in range(inp_chapter):
	(li, ri) = list(map(int, input().split()))
	matrix.append(li)
	matrix.append(ri)
inp_page = int(input())
for y in range(0, len(matrix), 2):
	num = num + 1
	if matrix[y] <= inp_page <= matrix[y + 1]:
		print(inp_chapter + 1 - num)


n = int(input())
x = []
z = n
for i in range(1, n + 1):
	(l_i, r_i) = map(int, input().split())
	x.append(l_i)
	x.append(r_i)
k = int(input())
for i in range(0, n):
	if x[2 * i] <= k <= x[2 * i + 1]:
		break
	else:
		z = z - 1
print(z)


t = int(input())
D = []
while t:
	D.append(tuple(map(int, input().split())))
	t -= 1
t = int(input())
for i in range(len(D)):
	if D[i][0] <= t <= D[i][1]:
		print(len(D) - i)
		break


n = int(input())
a = list()
for _ in range(n):
	(x, y) = map(int, input().split())
	a.append(y)
k = int(input())
for (i, num) in enumerate(a):
	if num >= k:
		print(n - i)
		break


n = int(input())
l = []
r = []
for i in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	r.append(y)
k = int(input())
for i in range(n):
	if l[i] <= k and k <= r[i]:
		print(n - i)


li = []
r = 0
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	li.append(l)
li.append(r + 1)
k = int(input())
cnt = 0
for _ in li:
	if k < _:
		cnt += 1
print(cnt)


n = int(input())
pch = []
for i in range(n):
	(l, r) = map(int, input().split())
	pch.append([l, r])
k = int(input())
nchprd = 0
for i in pch:
	if k > i[1]:
		nchprd += 1
	elif k >= i[0] and k <= i[1]:
		break
print(n - nchprd)


n = int(input())
chapters = []
for i in range(n):
	chapter = list(map(int, input().split()))
	chapters.append(chapter)
k = int(input())

def read(chapter):
	if k > chapter[1]:
		return 0
	return 1
print(sum(map(read, chapters)))


n = int(input())
k = []
for _ in range(n):
	(l, r) = map(int, input().split())
	k.append(r)
val = int(input())
if val <= k[0]:
	print(n)
elif val > k[len(k) - 1]:
	print(0)
elif val == k[len(k) - 1]:
	print(1)
else:
	for i in range(n):
		if val <= k[i]:
			print(n - i)
			flag = 1
			break
	if flag == 0:
		print(n)


n = int(input())
C = []
for i in range(0, n):
	C.append(list(map(int, input().split())))
k = int(input())
for (x, c) in enumerate(C):
	if k <= c[1]:
		break
print(n - x)


n = int(input())
end = []
for i in range(n):
	t = input().split()
	end.append(int(t[1]))
k = int(input())
print(len([i for i in end if i >= k]))


n = int(input())
s = n
c = []
for i in range(n):
	(l, r) = list(map(int, input().split()))
	c.append((l, r))
k = int(input())
for (l, r) in c:
	if l <= k <= r:
		break
	else:
		s -= 1
print(s)


n = int(input())
booknum = []
for i in range(1, n + 1):
	(a, b) = map(int, input().split())
	booknum.append(b)
k = int(input())
for i in range(0, n):
	if booknum[i] >= k:
		print(n - i)
		break


n = int(input())
b = []
for i in range(n):
	chap = [int(x) for x in input().split()]
	length = chap[1] - chap[0] + 1
	b += [i + 1] * length
print(n - b[int(input()) - 1] + 1)


n = int(input())
array = [list(map(int, input().split())) for _ in range(n)]
t = int(input())
count = 0
for pair in array:
	if pair[0] <= t <= pair[1] or t <= pair[0]:
		count += 1
print(count)


__author__ = 'NIORLYS'
n = int(input())
chapters = [None] * n
for i in range(n):
	chapters[i] = list(map(int, input().split()))
k = int(input())
chapters_to_read = 0
i = None
for i in range(n):
	if chapters[i][0] <= k <= chapters[i][1]:
		chapters_to_read += 1
		break
print(chapters_to_read + n - (i + 1))


n = int(input())
a = []
q = 0
for i in range(n):
	(c, d) = map(int, input().split())
	a.append(d)
x = int(input())
for i in a:
	if x > i:
		q = q + 1
	else:
		break
print(n - q)


n = int(input())
(x, y) = ([], [])
for i in range(n):
	(r, l) = map(int, input().split())
	for j in range(r, l + 1):
		x.append(j)
	y.append(x)
	x = []
d = int(input())
for i in range(len(y)):
	if d in y[i]:
		print(len(y[i:]))
		exit()


n = int(input())
chapters = []
for i in range(n):
	t = input()
	chapters.append(tuple(list(map(int, t.split()))))
sa = int(input())
stop = False
for i in range(n):
	if chapters[i][0] <= sa <= chapters[i][1]:
		left = n - i
print(left)


n = int(input())
a = []
for i in range(n):
	a.append(input().split())
m = int(input())
z = n
for i in range(n):
	if int(a[i][1]) < m:
		z = n - i - 1
print(z)


a = []
b = []
n = int(input())
for i in range(n):
	(c, d) = map(int, input().split())
	a.append(c)
	b.append(d)
k = int(input())
for i in range(n):
	if k >= a[i] and k <= b[i]:
		print(n - i)


n = int(input())
ar = []
for x in range(n):
	(l, r) = map(int, input().split())
	ar.append([l, r])
e = int(input())
ans = 0
mx = 0
for x in range(n):
	if e > ar[x][1]:
		mx = x + 1
print(n - mx)


n = int(input())
ip = [list(map(int, input().split())) for _ in range(n)]
tgt = int(input())
for i in range(n):
	if ip[i][0] <= tgt <= ip[i][1]:
		print(n - i)
		break


import os
import sys
if 'DEBUG' in os.environ:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = int(input())
pairs = []
for _ in range(n):
	(x, y) = map(int, input().split())
	pairs.append((x, y))
k = int(input())
for (i, p) in enumerate(pairs):
	if k >= p[0] and k <= p[1]:
		print(n - i)


n = int(input())
b = []
for i in range(n):
	b.append([int(x) for x in input().split()])
k = int(input())
for i in range(len(b)):
	if k >= b[i][0] and k <= b[i][1]:
		print(n - i)


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


n = int(input())
la = []
for i in range(n):
	la.append(list(map(int, input().split())))
m = int(input())
sum = 0
while m > la[sum][1]:
	sum += 1
print(n - sum)


a = int(input())
lst = []
count = 0
for i in range(a):
	(b, c) = map(int, input().split())
	lst.append(c)
d = int(input())
for i in lst:
	if i < d:
		count += 1
print(a - count)


capitulos = int(input())
livro = []
for i in range(capitulos):
	(primeira_pagina, segunda_pagina) = [int(i) for i in input().split()]
	livro.append({'capitulo': i, 'paginas': list(range(primeira_pagina, segunda_pagina + 1))})
k = int(input())
i = 0
searching = True
result = 0
while searching:
	if k in livro[i]['paginas']:
		searching = False
		result = capitulos - i
	i += 1
print(result)


n = int(input())
v = []
for i in range(n):
	(a, b) = map(int, input().split())
	v.append(b)
k = int(input())
for i in range(len(v)):
	if v[i] >= k:
		print(len(v) - i)
		break
else:
	print('0')


n = int(input())
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	m = list(range(l, r + 1))
	a.append(m)
k = int(input())
s = len(a)
for i in a:
	for j in range(len(i)):
		if i[j] == k:
			print(s)
	s = s - 1


n = int(input())
data = []
c = 0
for i in range(n):
	(a, b) = map(int, input().split())
	data.append(b)
k = int(input())
for i in data:
	if k > i:
		c += 1
	else:
		break
print(n - c)


k = int(input())
a = []
for i in range(k):
	a.append(int(input().split()[1]))
r = int(input())
rez = 0
for i in a:
	if r > i:
		rez += 1
	else:
		break
print(k - rez)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, 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 LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

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

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

def S():
	return input()

def main():
	n = I()
	l = [LI() for _ in range(n)]
	a = I()
	for (i, x) in enumerate(l):
		if x[0] <= a and a <= x[1]:
			return n - i
print(main())


n = int(input())
li = []
read = 0
for a in range(n):
	(x, y) = map(int, input().split())
	li.append(x)
	li.append(y)
k = int(input())
for a in range(0, len(li) - 2, 2):
	if k > li[a + 1]:
		read += 1
	else:
		pass
print(n - read)


l = []
r = []
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l.append(a)
	r.append(b)
k = int(input())
flag = 0
for (a, b) in zip(l, r):
	if k in range(a, b + 1):
		print(len(l) - l.index(a))
		flag = 1
		break
if flag == 0:
	print(0)


def left_chapter(total_chapter, chapter_list, current_page):
	assert total_chapter == len(chapter_list), 'invalid input'
	assert current_page <= chapter_list[len(chapter_list) - 1][1], 'invalid input'
	current_chapter = 0
	for (index, (start, end)) in enumerate(chapter_list):
		if current_page >= start and current_page <= end:
			current_chapter = index
			break
	return total_chapter - current_chapter
total_chapter = int(input())
chapter_list = list()
for i in range(total_chapter):
	chapter_list.append(tuple((int(i) for i in input().split(' '))))
current_page = int(input())
print(left_chapter(total_chapter, chapter_list, current_page))


chapters = int(input())
completed = 0
book = []
for _ in range(chapters):
	book.append(list(map(int, input().split()))[1])
k = int(input())
for i in range(chapters):
	if k <= book[i]:
		break
	else:
		completed += 1
print(chapters - completed)


n = int(input())
a = []
i = 0
while i < n:
	a.append(list(map(int, input().split())))
	i += 1
k = int(input())
i = 0
for x in a:
	if x[0] <= k <= x[1]:
		print(n - i)
		break
	i += 1


n = int(input())
chapters = [tuple(map(int, input().split())) for x in range(n)]
k = int(input())
i = 0
while i < n and k > chapters[i][1]:
	i += 1
print(n - i)


n = int(input())
a = []
j = n
for i in range(n):
	s = list(map(int, input().split()))
	a.append(s[1])
b = int(input())
for i in range(n):
	if b > a[i]:
		j = j - 1
	else:
		break
print(j)


n = int(input())
a = [0] * n
for i in range(n):
	(x, a[i]) = map(int, input().split())
i = 0
k = int(input())
while a[i] < k:
	i += 1
print(n - i)


n = int(input())
b = [list(map(int, input().split())) for _ in range(n)]
k = int(input())
for i in range(n):
	if b[i][0] <= k <= b[i][1]:
		print(n - i)


n = int(input())
c = [[*map(int, input().split())] for _ in range(n)]
k = int(input())
for (i, lr) in enumerate(c):
	(l, r) = lr
	if l <= k <= r:
		print(n - i)
		exit()
print(0)


n = int(input())
d = {}
for c in range(1, n + 1):
	d[c] = list(map(int, input().split()))
k = int(input())
for c in d.keys():
	if k >= d[c][0] and k <= d[c][1]:
		print(n - c + 1)
		break


n = int(input())
pages = [[int(x) for x in input().split()] for j in range(n)]
k = int(input())
ans = -1
for i in range(n):
	if k >= pages[i][0] and k <= pages[i][1]:
		ans = n - i
print(ans)


n = int(input())
inpL = []
for z in range(n):
	inpL.append([int(x) for x in input().split()])
k = int(input())
for i in range(n):
	if inpL[i][0] <= k <= inpL[i][1]:
		print(n - i)
		break


n = int(input())
dictPart = {}
for i in range(1, n + 1):
	arr = list(map(int, input().split()))
	dictPart[i] = arr
num = int(input())
for (item, value) in dictPart.items():
	if num in range(value[0], value[1] + 1):
		print(n - item + 1)


from sys import stdin
n = int(input())
l = []
for i in range(n):
	l = l + list(map(int, input().split()))
s = int(input())
l.append(s)
l.sort()
print(len(l[l.index(s):]) // 2)


a = int(input())
r = 0
b = list()
while r < a:
	(x, y) = [int(x) for x in input().split()]
	b.append(x)
	b.append(y)
	r = r + 1
c = int(input())
r = 0
while r < len(b):
	if b[r] >= c:
		d = len(b) - (r + 1)
		break
	r = r + 1
print(d // 2 + 1)


n = int(input())
a = [[] * 2] * n
for i in range(n):
	a[i] = (int(j) for j in input().split())
k = int(input())
ind = 0
for (l, r) in a:
	if l <= k <= r:
		print(n - ind)
		break
	ind += 1


n = int(input())
l = []
r = []
for _ in range(n):
	(li, ri) = [int(x) for x in input().split()]
	l.append(li)
	r.append(ri)
k = int(input())
res = None
i = 0
while not res and i < n:
	if l[i] <= k <= r[i]:
		res = i
	i += 1
print(n - res)


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

def chRemain(n, chs, m):
	for i in range(n):
		if m <= chs[i]:
			return n - i
print(chRemain(n, chs, m))


n = int(input())
lst = list()
for i in range(n):
	(m, n) = map(int, input().split())
	lst.append([m, n])
cp = int(input())
for i in range(len(lst)):
	if cp <= lst[i][-1]:
		print(len(lst) - i)
		break


n = int(input())
l = [None] * n
for i in range(n):
	l[i] = [int(o) for o in input().split()]
a = int(input())
s = 0
for i in range(n):
	if a <= l[i][1] and a >= l[i][0]:
		s = n - i
		break
print(s)


gi = lambda : list(map(int, input().strip().split()))
(n,) = gi()
L = [gi() for e in range(n)]
(K,) = gi()
ans = n
cur = 0
while ans > 0:
	if K > L[cur][1]:
		cur += 1
		ans -= 1
	else:
		break
print(ans)


nCap = int(input())
cap = []
for i in range(nCap):
	(firstPage, lastPage) = [int(i) for i in input().split()]
	cap.append(lastPage)
k = int(input())
readed = 0
for i in range(nCap):
	if k <= cap[i]:
		break
	if k > cap[i]:
		readed += 1
print(nCap - readed)


n = int(input())
chaps = []
for i in range(n):
	(l, r) = map(int, input().split())
	chaps.append(r)
k = int(input())
red = 0
for i in range(n):
	if chaps[i] >= k:
		print(n - red)
		break
	else:
		red += 1


n = int(input())
np = [0]
for _ in range(n):
	(l, r) = map(int, input().split())
	np.append(np[-1] + r - l + 1)
tn = int(input())
for i in range(n + 1):
	if tn <= np[i]:
		print(n - i + 1)
		break


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from itertools import *
from collections import Counter
N = int(stdin.readline())
L = []
for n in range(N):
	(l, r) = map(int, stdin.readline().rstrip().split())
	L.append([l, r])
K = int(stdin.readline())
if K == 1:
	print(N)
else:
	ans = 0
	for i in range(len(L)):
		if L[i][1] >= K:
			ans = N - i
			break
	print(ans)


n = int(input())
chapters = []
for i in range(n):
	line = input().split()
	chapters.append([int(line[0]), int(line[1])])
last = int(input())
ans = 0
for chapter in chapters:
	if chapter[1] >= last:
		ans += 1
print(ans)


n = int(input())
s = []
t = 0
for i in range(0, n):
	[l, r] = map(int, input().split())
	s.append([l, r])
k = int(input())
for i in range(0, n):
	for j in range(s[i][0], s[i][1] + 1):
		if k == j:
			t = t + 1
			l = i
			break
print(t + n - (l + 1))


def solve(c, p, b):
	for i in range(0, len(p)):
		if b in range(p[i][0], p[i][-1] + 1):
			print(len(p) - i)

def main():
	c = int(input())
	p = list()
	for i in range(c):
		p.append([int(x) for x in input().split()])
	b = int(input())
	solve(c, p, b)
main()


def solve():
	n = int(input())
	lasts = []
	for _ in range(n):
		(f, l) = map(int, input().split())
		lasts.append(l)
	left = int(input())
	read = 0
	for num in lasts:
		if num < left:
			read += 1
		else:
			break
	return n - read
print(solve())


import functools
import itertools

def p_a():
	line = input()
	(a, mean) = list(map(int, line.split(' ')))
	print(mean * 2 - a)

class p_b_data:

	def __init__(self):
		self.data = {}

	def compare(self, x, y):
		if self.data[x] < self.data[y]:
			return 1
		elif self.data[x] > self.data[y]:
			return -1
		else:
			if x < y:
				return -1
			return 1

def p_b():
	num_students = int(input())
	data = p_b_data()
	for i in range(num_students):
		score = sum(list(map(int, input().split(' '))))
		data.data[i] = score
	students = [i for i in range(num_students)]
	a = sorted(students, key=functools.cmp_to_key(data.compare))
	print(a.index(0) + 1)

def p_c():
	num_chapters = int(input())
	chapter_pages = [0 for i in range(num_chapters)]
	total_pages = 0
	for i in range(num_chapters):
		(start_pg, end_pg) = list(map(int, input().split(' ')))
		chapter_pages[i] = end_pg
	total_pages = chapter_pages[-1]
	marked_pg = int(input())
	read_chapters = [1 if chapter_pages[i] < marked_pg else 0 for i in range(num_chapters)]
	print(num_chapters - read_chapters.index(0))

def sum_digits(num):
	ret = 0
	while num:
		ret += num % 10
		num //= 10
	return ret

def p_d():
	while True:
		num = int(input())
		num_sum = sum_digits(num)
		if not num:
			break
		for i in itertools.count(11):
			if num_sum == sum_digits(i * num):
				print(i)
				break

def main():
	p_c()
main()


n = int(input())
a = []
gl = 0
for i in range(n):
	a.append(list(map(int, input().split())))
k = int(input())
for i in range(n):
	if a[i][1] >= k:
		gl = n - i
		break
print(gl)


a = int(input())
b = []
for i in range(a):
	(c, d) = map(int, input().split())
	b.append(c)
	b.append(d)
e = int(input())
f = 1
ans = 0
while f != 100:
	if b[f] < e:
		ans += 1
		f += 2
	else:
		f = 100
print(a - ans)


import sys

def rint():
	return map(int, sys.stdin.readline().split())
n = int(input())
r = []
for i in range(n):
	(t1, t2) = rint()
	r.append([t1, t2])
k = int(input())
for i in range(n):
	if k > r[i][1]:
		continue
	if k <= r[i][1]:
		print(n - i)
		exit()


n = int(input())
fi = []
c = 0
for i in range(n):
	(l, r) = map(int, input().split())
	fi.append([l, r])
m = int(input())
for i in range(n):
	if m >= fi[i][0] and m <= fi[i][1]:
		c = i + 1
		break
print(n + 1 - c)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def solve():
	N = Scanner.int()
	P = Scanner.int_list_list(N)
	K = Scanner.int()
	for (i, p) in enumerate(P):
		if p[0] <= K <= p[1]:
			print(N - i)
			return

def main():
	solve()
main()


x = int(input())
z = list(range(x))
t = 0
t1 = x
for i in range(0, x):
	temp = map(int, input().split(' '))
	(n, n1) = temp
	z[t] = n1
	t = t + 1
x1 = int(input())
for i in range(0, x):
	if z[i] < x1:
		t1 = t1 - 1
	else:
		break
print(t1)


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


n = int(input())
right = []
for _ in range(n):
	(l, r) = map(int, input().split())
	right.append(r)
page = int(input())
for i in range(n):
	if page <= right[i]:
		print(n - i)
		break


b = []
n = int(input())
for i in range(n):
	ch = []
	ch = list(map(int, input().split()))
	b.append(ch)
k = int(input())
count = 0
for j in range(n):
	if k <= b[j][0] or k <= b[j][1]:
		count = count + 1
print(count)


from bisect import bisect_left
chapters = int(input())
pages = []
for _ in range(chapters):
	(l, r) = map(int, input().split())
	pages.append(r)
k = int(input())
chapter = bisect_left(pages, k)
print(chapters - chapter)


n = int(input())
chapters = []
for _ in range(n):
	chapters.append(list(map(int, input().split())))
k = int(input())
i = 0
while i < n:
	if k <= chapters[i][1]:
		break
	else:
		i += 1
print(n - i)


chap = int(input())
pages = []
for i in range(chap):
	temp = [int(x) for x in input().split()]
	pages.append(temp[1])
last = int(input())
if last >= pages[chap - 1]:
	print(1)
elif last <= pages[0]:
	print(chap)
else:
	left = 0
	right = chap - 1
	ans = 0
	while left <= right:
		mid = (left + right) // 2
		if pages[mid] == last:
			ans = chap - mid
			break
		if pages[mid] > last:
			right = mid - 1
			ans = chap - mid
		else:
			left = mid + 1
			ans = chap - mid - 1
	print(ans)


x = int(input())
l = []
for i in range(x):
	l.extend(map(int, input().split()))
y = int(input())
for i in range(1, len(l) + 1, 2):
	if l[i] >= y:
		print(x - i // 2)
		break


try:
	n = int(input())
	l = []
	for i in range(n):
		(x, y) = map(int, input().split())
		l.append((x, y))
	k = int(input())
	for i in range(n):
		if k >= l[i][0] and k <= l[i][1]:
			print(n - i)
			break
except EOFError:
	pass


n = int(input())
tab = []
for x in range(n):
	(l, r) = map(int, input().split())
	tab.append((l, r))
i = int(input())
for x in range(n):
	if i >= tab[x][0] and i <= tab[x][1]:
		print(len(tab) - x)
		break


totalchapter = int(input())
nochapter = [[int(x) for x in input().split()] for _ in range(totalchapter)]
count = 0
drop = int(input())
for i in range(totalchapter):
	if nochapter[i][-1] >= drop:
		count = totalchapter - i
		break
print(count)


import sys
nchapters = 0
chapters = []
marked = 0
for (place, line) in enumerate(sys.stdin):
	numbers = [int(i) for i in line.split()]
	if place == 0:
		nchapters = numbers[0]
	elif len(numbers) == 2:
		chapters.append(tuple(numbers))
	else:
		marked = numbers[0]
for (idx, chapter) in enumerate(chapters):
	if chapter[0] <= marked and chapter[1] >= marked:
		print(nchapters - idx)
		exit(0)


from bisect import bisect_left as bs
n = int(input())
a = [int(input().split()[1]) for _ in range(n)]
k = int(input())
print(n - bs(a, k))


n = int(input())
tab = []
for i in range(n):
	(x, y) = map(int, input().split())
	tab.extend([x, y])
k = int(input())
for i in range(0, 2 * n, 2):
	if k >= tab[i] and k <= tab[i + 1]:
		print(int(n - i / 2))
		break


n = int(input())
chapters = list()
for i in range(n):
	chapters.append(tuple(map(int, input().split())))
k = int(input())
ans = 0
l = 1
for i in chapters:
	if i[0] <= k <= i[1]:
		ans = l
		break
	l += 1
print(n - ans + 1)


n = int(input())
data = []
for _ in range(n):
	data.append([int(x) for x in input().split(' ')])
k = int(input())
for (i, (l, r)) in enumerate(data):
	if k >= l and k <= r:
		print(n - i)


num = int(input())
q = list()
for i in range(num):
	(a, b) = [int(i) for i in input().split()]
	q.append((a, b))
r = int(input())
for (i, x) in enumerate(q):
	if r <= x[1]:
		print(num - i)
		break


n = int(input())
t = []
for i in range(n):
	t += [int(i) for i in input().split(' ')]
ch = int(input())
t.append(ch)
t.sort()
print(n - t.index(ch) // 2)


n = int(input())
l = []
for i in range(n):
	l1 = list(map(int, input().split(' ')))
	for t in l1:
		l.append(t)
s = int(input())
c = 0
for i in range(0, len(l) - 1, 2):
	if s >= l[i] and s <= l[i + 1]:
		r = c
	else:
		c = c + 1
print(n - r)


n = int(input())
ans = 0
begin = []
end = []
for i in range(n):
	(l, r) = map(int, input().split())
	begin.append(l)
	end.append(r)
k = int(input())
for i in range(len(end)):
	if end[i] >= k:
		ans += 1
print(ans)


import sys
from math import floor, ceil, log2
inp = lambda : sys.stdin.readline().strip()
n = int(inp())
a = []
for i in range(n):
	(l, r) = map(int, inp().split())
	a.append((l, r))
k = int(inp())
for i in range(n):
	if a[i][0] <= k and k <= a[i][1]:
		print(n - i)
		break


chapters = int(input())
book = []
for i in range(chapters):
	(begin, end) = [int(e) for e in input().split()]
	book.append([begin, end])
k = int(input())
chapter_stoped = 0
for i in range(chapters):
	if k >= book[i][0] and k <= book[i][1]:
		chapter_stoped = i
		break
print(chapters - chapter_stoped)


cap = int(input())
pages = []
for i in range(cap):
	(comeco, final) = input().split()
	comeco = int(comeco)
	final = int(final)
	pages.append(comeco)
	pages.append(final)
k = int(input())
for i in range(1, 2 * cap, 2):
	if pages[i] >= k:
		print((cap * 2 - 1 - i) // 2 + 1)
		break


n = int(input())
chapters = [list(map(int, input().split(' '))) for _ in range(n)]
k = int(input())
for chapter in chapters:
	if k > chapter[1]:
		n -= 1
	elif k <= chapter[1]:
		print(n)
		exit()
print(n)


n = int(input())
c = []
for i in range(n):
	(a, b) = map(int, input().split())
	c.append(b)
m = int(input())
for i in c:
	if m <= i:
		print(n - c.index(i))
		break


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
k = int(input())
for i in range(n):
	for j in range(l[i][0], l[i][1] + 1):
		if j == k:
			print(n - i)


n = int(input())
ps = [[0, 0] for i in range(n)]
for i in range(n):
	ps[i] = list(map(int, input().split()))
k = int(input())
if n == 1:
	print(0 if ps[0][1] < k else 1)
else:
	c = 0
	for i in range(1, n):
		if ps[i][0] <= k:
			c += 1
	if k > ps[n - 1][1]:
		c += 1
	print(n - c)


def binarySearch(arr, l, r, x):
	ans = 0
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
			ans = mid
		else:
			r = mid - 1
	return ans
n = int(input())
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	a.append(l)
k = int(input())
ans = binarySearch(a, 0, len(a) - 1, k)
print(n - ans)


n = int(input())
gl = []
for i in range(n):
	a = input().split()
	gl.append([int(a[0]), int(a[1])])
os = int(input())
ans = 0
for i in range(n):
	if os <= gl[i][1] and os >= gl[i][0]:
		ans = i
		break
ans = n - ans
print(ans)


def rli():
	return list(map(int, input().split()))

def main():
	n = int(input())
	ns = []
	for i in range(n):
		(x, y) = rli()
		ns.append((x, y))
	w = int(input())
	for i in range(n):
		(x, y) = ns[i]
		if y >= w:
			print(n - i)
			return

def __starting_point():
	main()
__starting_point()


n = int(input())
d = []
c = 0
for i in range(n):
	(a, b) = map(int, input().split())
	d.append(b)
k = int(input())
for i in range(len(d)):
	if d[i] >= k:
		c += 1
print(c)


n = int(input())
l = []
for i in range(n):
	s = input().split()
	l.append(s)
k = int(input())
for i in range(n):
	if int(l[i][0]) <= k <= int(l[i][1]):
		print(len(l) - i)
		break


N = int(input())
L = [tuple(map(int, input().split())) for i in range(N)]
k = int(input())
for (i, x) in enumerate(L):
	if k <= x[1]:
		break
print(N - i)


n = int(input())
arr = []
for i in range(n):
	(l, r) = map(int, input().strip().split())
	arr.append([l, r])
k = int(input())
nm = -1
for i in range(n):
	if arr[i][0] <= k and arr[i][1] >= k:
		nm = i
		break
if nm == -1:
	print(n)
else:
	print(n - i)


n = int(input())
l = []
r = []
for chapter in range(n):
	(a, b) = input().split()
	l.append(int(a))
	r.append(int(b))
zipped_l_r = list(zip(l, r))
k = int(input())
check = True
left = 0
right = len(zipped_l_r) - 1
while check:
	mid_idx = (left + right) // 2
	if zipped_l_r[mid_idx][0] <= k <= zipped_l_r[mid_idx][1]:
		res = len(zipped_l_r) - mid_idx
		print(res)
		check = False
	elif k > zipped_l_r[mid_idx][1]:
		left = mid_idx + 1
	elif k < zipped_l_r[mid_idx][0]:
		right = mid_idx


t = []
n = int(input())
for i in range(n):
	(l, r) = [int(x) for x in input().split()]
	t.append(r)
k = int(input())
for i in range(n):
	if k <= t[i]:
		print(n - i)
		break


n = int(input())
pages = []
for _ in range(n):
	(l, r) = map(int, input().split())
	pages.append([l, r])
k = int(input())
i = 0
for g in range(len(pages)):
	if k >= pages[g][0] and k <= pages[g][1]:
		i = g
		break
print(n - i)


n1 = int(input())
(m, count) = ([], 0)
for i in range(n1):
	(x, y) = map(int, input().split())
	m.append(y)
n = int(input())
if n1 == 1:
	print(1)
else:
	for i in range(len(m)):
		if m[i] < n:
			count += 1
	print(n1 - count)


n = int(input())
b = []
j = n
for i in range(n):
	a = [int(i) for i in input().split()]
	b += [a]
k = int(input())
for i in range(len(b)):
	if b[i][0] <= k and b[i][1] >= k:
		if i + 1 == n:
			j = 1
			break
		else:
			break
	else:
		j -= 1
print(j)


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
k = int(input())
print(sum((int(i[1] >= k) for i in a)))


import bisect
n = int(input())
chapters = []
for chapter in range(n):
	chapters.append([int(s) for s in input().split(' ')][1])
k = int(input())
x = bisect.bisect_left(chapters, k)
print(n - x)


n = int(input())
List = []
for _ in range(n):
	(a, b) = map(int, input().split())
	List.append(a)
	List.append(b)
k = int(input())
i = 0
j = 1
for l in range(n):
	if k >= List[i] and k <= List[j]:
		print(n - l)
		break
	else:
		i += 2
		j += 2


n = int(input())
p = []
for _ in range(n):
	p.append([int(x) for x in input().split()])
k = int(input())
for i in range(n):
	if k <= p[i][1]:
		break
print(n - i)


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
n = ii()
a = [li() for _ in range(n)]
k = ii()
ans = 0
for (l, r) in a:
	ans += k <= r
print(ans)


n = int(input())
ends = []
for _ in range(n):
	(first, last) = map(int, input().split())
	ends.append(last)
k = int(input())
c = 0
for e in ends:
	if k <= e:
		c += 1
print(c)


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


n = int(input())
chapters = []
for _ in range(n):
	(a, b) = map(int, input().strip().split())
	chapters.append((a, b))
k = int(input())
count = n
for i in range(n):
	(a, b) = chapters[i]
	if k > b:
		count -= 1
	else:
		break
print(count)


n = int(input())
l = [0] * n
r = [0] * n
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
x = int(input())
y = 0
for i in range(n):
	if r[i] < x:
		y += 1
	else:
		break
print(n - y)


n = int(input())
m = []
while n != 0:
	(l, r) = map(int, input().split())
	m.append(l)
	m.append(r)
	n -= 1
k = int(input())
for i in range(len(m)):
	if k <= m[i]:
		print(int((len(m) - i + 1) / 2))
		break


first = []
not_read_chapters = 0
number = int(input())
for i in range(number):
	second = max(list(map(int, input().split())))
	first.append(second)
mark_point = int(input())
for i in first:
	if mark_point <= i:
		print(len(first) - first.index(i))
		break


def main():
	n = int(input())
	data = []
	for i in range(n):
		(s, f) = [int(v) for v in input().split()]
		data.append((s, f))
	p = int(input())
	print(len([d for d in data if p <= d[0] or d[0] <= p <= d[1]]))
main()


n = int(input())
a = []
for i in range(n):
	(p, q) = map(int, input().split()[:2])
	a.append(q)
k = int(input())
for i in range(n):
	if k <= a[i]:
		c = n - i
		break
print(c)


import sys
n = int(input())
lr = []
rr = []
suma = n
for i in range(n):
	(l, r) = map(int, sys.stdin.readline().split())
	lr.append(l)
	rr.append(r)
k = int(input())
for i in range(n):
	if k >= lr[i] and k <= rr[i]:
		suma = n - i
		break
	else:
		suma -= 1
print(suma)


n = int(input())
s = []
for i in range(n):
	s.append(input().split(' '))
x = int(input())
t = 0
for i in range(n):
	if x <= int(s[i][1]):
		t = n - i
		break
print(t)


num = int(input())
max_ = []
count = 0
for i in range(num):
	(x, y) = map(int, input().split())
	maxi = max(x, y)
	max_.append(maxi)
k = int(input())
for j in max_:
	if k > j:
		count = count + 1
	else:
		continue
print(num - count)


n = int(input())
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append([a, b])
t = int(input())
i = 0
while t > l[i][1]:
	i += 1
print(n - i)


n = int(input())
c = []
for i in range(n):
	c.append([int(i) for i in input().split()])
k = int(input())
for i in range(len(c)):
	if c[i][1] < k:
		continue
	else:
		print(n - i)
		break


n = int(input())
j = n
l = []
while int(n) > 0:
	t = input().split()
	l.append(int(t[1]))
	t = []
	n = n - 1
c = int(input())
i = 0
index = 0
while i < j:
	if c <= l[i]:
		index = i
		break
	else:
		i = i + 1
print(j - index)


n = int(input())
(nl, ml) = ([], [])
val = 0
for i in range(n):
	(l, r) = map(int, input().strip().split())
	nl.append(l)
	ml.append(r)
k = int(input())
for i in range(n):
	if k >= nl[i] and k <= ml[i]:
		break
	else:
		val += 1
print(n - val)


n = int(input())
lst = []
k = 0
for i in range(n):
	n1 = list(map(int, input().split()))
	lst.append(n1)
n2 = int(input())
for j in lst:
	if n2 > j[1]:
		continue
	k = k + 1
print(k)


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
a.sort(key=lambda x: x[0])
k = int(input())
c = n
for i in range(n):
	if k >= a[i][0] and k <= a[i][1]:
		c = i
		break
print(n - c)


from math import ceil
l = []
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	l.append(x)
	l.append(y)
val = int(input())
low = 0
ri = len(l) - 1
for i in range(len(l)):
	if l[i] == val:
		print(ceil((len(l) - i) / 2))
		break
	elif l[i] < val and l[i + 1] > val:
		print(ceil((len(l) - (i + 1)) / 2))
		break


n = int(input())
allchapter = []
for i in range(n):
	ch = [int(i) for i in input().split(' ')]
	allchapter.append(ch)
k = int(input())
c = 0
for i in range(len(allchapter)):
	if k >= allchapter[i][0] and k <= allchapter[i][1]:
		c = i
		break
print(n - c)


n = int(input())
a = []
for j in range(n):
	(l, r) = map(int, input().split())
	a.append(l)
	a.append(r)
k = int(input())
if k != 1:
	for i in range(len(a)):
		if a[i] < k and k <= a[i + 1]:
			print((len(a) - i) // 2)
else:
	print(n)


T = int(input())
lst = []
for i in range(T):
	(l, r) = map(int, input().split())
	lst.append(r)
k = int(input())
c = 0
for i in lst:
	if i >= k:
		c += 1
print(c)


import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10 ** 9 + 7
n = int(input())
a = [[] for i in range(n)]
for i in range(n):
	(l, r) = map(int, input().split())
	a[i] = [l, r]
k = int(input())
ans = n
for i in a:
	if i[1] < k:
		ans -= 1
	else:
		break
print(ans)


noOfChapters = int(input())
chapterPages = []
for i in range(noOfChapters):
	tokens = input().split()
	tokens = [int(x) for x in tokens]
	chapterPages.append(tokens)
currentPage = int(input())
count = 0
for i in range(noOfChapters):
	if chapterPages[i][1] < currentPage:
		count += 1
print(noOfChapters - count)


import math
t = int(input())
m = t
arr = []
while t:
	(a, b) = list(map(int, input().split()))
	arr.append(a)
	arr.append(b)
	t = t - 1
c = int(input())
p = 0
for i in range(len(arr)):
	if c <= arr[i]:
		p = i
		break
print(m - math.floor(p / 2))


n = int(input())
p = []
for x in range(n):
	(a, b) = list(map(int, input().split()))
	sam = list(range(a, b + 1))
	p.append(sam)
kam = int(input())
for x in p:
	if kam in x:
		print(n - p.index(x))
		break


chapters = int(input())
starts = []
ends = []
for i in range(chapters):
	(start, end) = list(map(int, input().split()))
	starts.append(start)
	ends.append(end)
marked = int(input())
unread = 0
for i in range(len(starts)):
	if marked <= ends[i]:
		unread += 1
print(unread)


n = int(input())
a = [0] * 50001
for i in range(n):
	(l, r) = list(map(int, input().split()))
	for j in range(l, r + 1):
		a[j] = i
k = int(input())
print(n - a[k])


from sys import stdin
n = int(stdin.readline())
arr = []
for i in range(n):
	(a, b) = map(int, stdin.readline().split())
	arr.append(b)
k = int(stdin.readline())
cond = False
for i in range(n):
	if k <= arr[i]:
		cond = True
		print(n - i)
		break
	else:
		pass
if cond == False:
	print(0)


n = int(input())
l = []
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	l.append((a, b))
m = int(input())
for i in range(0, len(l)):
	if m <= max(l[i]):
		count = i
		break
print(len(l) - count)


import sys
import math, bisect
sys.setrecursionlimit(10 ** 5)
from collections import defaultdict
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

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

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

def Neo():
	return list(map(int, sys.stdin.readline().split()))
N = I()
Ans = []
for i in range(N):
	(l, r) = neo()
	Ans.append((l, r))
k = I()
for i in range(N):
	t = Ans[i]
	if t[0] <= k <= t[1]:
		break
print(N - i)


n = int(input())
hasil = []
output = 0
for i in range(n + 1):
	if i != n:
		angka = input().split()
		hasil += [angka]
	else:
		hal = int(input())
		for j in range(len(hasil)):
			if output != 0:
				break
			for k in range(int(hasil[j][0]), int(hasil[j][1]) + 1):
				if k == hal:
					output = len(hasil) - j
					break
				else:
					output = 0
print(output)


capitulos = int(input())
paginas = [0] * capitulos
for i in range(capitulos):
	(paginas[i], descarte) = [int(x) for x in input().split()]
atual = int(input())
for x in range(capitulos):
	if atual >= paginas[x]:
		if x == capitulos - 1:
			cap = x
			x = capitulos
		elif atual < paginas[x + 1]:
			cap = x
			x = capitulos
print(capitulos - cap)


n = int(input())
page = []
for i in range(n):
	(l, r) = map(int, input().split())
	page.append([l, r])
k = int(input())
index = 0
flag = 0
for i in page:
	index += 1
	for j in range(i[0], i[-1] + 1):
		if k == j:
			flag = index
			break
print(n - flag + 1)


n = int(input())
s = []
res = 0
for i in range(n):
	(a, b) = map(int, input().split())
	s.append(b)
k = int(input())
for i in range(len(s)):
	if k <= s[i]:
		res += 1
print(res)


from sys import stdin, stdout
a = []
n = int(stdin.readline())
for j in range(n):
	a.append([int(x) for x in stdin.readline().split()])
a.append(int(stdin.readline()))
for k in range(n):
	if a[-1] >= a[k][0] and a[-1] <= a[k][1]:
		print(n - k)
		break


lr = [input().split() for _ in range(int(input()))]
k = int(input())
print(sum((int(lri[1]) >= k for lri in lr)))


n = int(input())
pages = []
for _ in range(n):
	pages.append(list(map(int, input().strip().split())))
k = int(input())
ans = None
for (i, pair) in enumerate(pages):
	if pair[0] <= k <= pair[1]:
		ans = n - i
		break
if ans is None:
	ans = 0
print(ans)


n = int(input())
a = []
for i in range(n):
	(l, r) = (int(x) for x in input().split())
	a.append(r)
k = int(input())
ans = n
for i in range(len(a)):
	if a[i] < k:
		ans = min(ans, n - i - 1)
print(ans)


def remaining_pages(x, arr):
	for i in range(len(arr)):
		if x <= arr[i]:
			return len(arr) - i
	return 0
end_pos = []
chapters = int(input().strip())
for x in range(0, chapters):
	(start, end) = map(int, input().rstrip().split())
	end_pos.append(end)
current_page = int(input().strip())
print(remaining_pages(current_page, end_pos))


n = int(input())
l = []
for _ in range(n):
	(a, b) = map(int, input().split())
	l.append((a, b))
k = int(input())
for i in range(n):
	if k >= l[i][0] and k <= l[i][1]:
		ans = i
		break
print(n - ans)


n = int(input())
t = []
for i in range(n):
	(l, r) = list(map(int, input().strip().split()))
	k = []
	for j in range(l, r + 1):
		k += [j]
	t += [k]
p = int(input())
for j in range(len(t)):
	if p in t[j]:
		c = j
		break
print(n - c)


q = lambda : map(int, input().split())
qi = lambda : int(input())
qs = lambda : input().split()
a = []
for _ in [0] * qi():
	a.append(list(q()))
s = qi()
print(sum([1 if x <= s <= y or (s < y and s < x) else 0 for (x, y) in a]))


n = int(input())
l = []
for i in range(n):
	l = l + [list(map(int, input().split()))]
k = int(input())
x = 0
for i in l:
	if k in range(i[0], i[1] + 1):
		print(n - l.index(i))
		break


n = int(input())
v = []
for i in range(n):
	v.append(int(input().split()[1]))
p = int(input())
for (pos, i) in enumerate(v):
	if i >= p:
		print(n - pos)
		break


n = int(input())
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	a.append([l, r])
g = int(input())
for i in range(n):
	if a[i][0] <= g <= a[i][1]:
		print(n - i)
		break


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 = I()
	a = [LI() for _ in range(n)]
	t = I()
	r = 0
	for (b, c) in a:
		if c >= t:
			r += 1
	return r
print(main())


from collections import defaultdict
d = defaultdict(int)
t = int(input())
for _ in range(t):
	(f, l) = [int(x) for x in input().split()]
	d[_] = l
k = int(input())
i = 0
while k > d[i]:
	i = i + 1
print(t - i)


n = int(input())
l1 = []
for i in range(n):
	l1.append(list(map(int, input().split())))
k = int(input())
for i in range(n):
	if l1[i][1] == k:
		print(n - i)
		break
	elif l1[i][1] > k:
		print(n - i)
		break


n = int(input())
a = []
for i in range(n):
	l = list(map(int, input().split()))
	a.append(l)
mark = int(input())
for i in range(n):
	if mark >= a[i][0] and mark <= a[i][1]:
		print(n - i)
		break


n = int(input())
chapters = []
for i in range(n):
	(start, end) = list(map(int, input().split(' ')))
	chapters.append((start, end))
k = int(input())
for i in range(len(chapters)):
	if k <= chapters[i][1]:
		unfinished = i
		break
print(len(chapters) - unfinished)


l = 0
z = []
x = int(input())
for n in range(x):
	(a, b) = map(int, input().split())
	z.append([a, b])
k = int(input())
for (n, j) in z:
	if n <= k <= j:
		break
	else:
		l += 1
print(x - l)


n = int(input())
chaps = []
for i in range(n):
	chaps.append(tuple(map(int, input().split())))
y = int(input())
count = 0
for i in range(n):
	if chaps[i][0] <= y and chaps[i][1] >= y:
		count = i
		break
print(n - count)


n = int(input())
l = []
r = []
for _ in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	r.append(y)
m = int(input())
for i in range(len(r)):
	if m <= r[i]:
		ind = i
		break
print(len(r) - ind)


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict
import math

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

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

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

def stringIn():
	return stdin.readline().strip()
n = intIn()
pages = []
for i in range(n):
	(l, r) = listIn()
	pages.append((l, r))
k = intIn()
for i in range(n):
	if k > pages[i][1]:
		continue
	else:
		ans = n - i
		break
print(ans)


n = int(input())
chapters = []
for i in range(n):
	(l, r) = map(int, input().split())
	chapters.append(r)
page = int(input())
rcount = 0
for i in range(n):
	if page > chapters[i]:
		rcount += 1
	else:
		break
print(n - rcount)


import sys
from math import *

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
n = mint()
a = [0] * n
for i in range(n):
	a[i] = tuple(mints())
k = mint() - 1
c = 0
for i in range(n):
	if k < a[i][1]:
		c += 1
print(c)


n = int(input())
(x, y) = ([], [])
for i in range(n):
	(l, r) = map(int, input().split())
	for j in range(l, r + 1):
		x.append(j)
	y.append(x)
	x = []
k = int(input())
for i in range(len(y)):
	if k in y[i]:
		print(len(y[i:]))
		break


nfchapters = int(input())
chapter_pages = []
for i in range(nfchapters):
	pgno = input()
	s = pgno.split(' ')
	a = [int(s[0]), int(s[1])]
	chapter_pages.append(a)
pgno_left = int(input())
count = 0
for j in range(len(chapter_pages)):
	if pgno_left >= chapter_pages[j][0] and pgno_left <= chapter_pages[j][1]:
		count = count + 1
	elif pgno_left <= chapter_pages[j][0]:
		count = count + 1
print(count)


N = int(input())
T = []
for i in range(N):
	(l, k) = map(int, input().split(' '))
	T.append(k)
k = int(input())
counter = 0
for i in range(len(T)):
	if T[i] >= k:
		counter = counter + 1
print(counter)


l = []
seen = []
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	l.append((x, y))
k = int(input())
for (x, y) in l:
	if k in range(x, y + 1):
		break
	else:
		seen.append((x, y))
print(len(l) - len(seen))


n = int(input())
data = [tuple(map(int, input().split())) for _ in range(n)]
curr = int(input())
for (i, v) in enumerate(data):
	if curr >= v[0] and curr <= v[1]:
		break
print(n - i)


n = int(input())
lista = []
for _ in range(n):
	(_, a) = map(int, input().split(' '))
	lista.append(a)
k = int(input())
for i in range(n):
	if lista[i] >= k:
		break
print(n - i)


n = int(input())
chap = []
for i in range(n):
	(l, r) = input().split(' ')
	l = int(l)
	r = int(r)
	chap.append(r)
k = int(input())
j = 0
while True:
	if k <= chap[j] or j == len(chap) - 1:
		break
	j += 1
print(n - j)


n = int(input())
chapters = []
for i in range(n):
	chapters.append(tuple(map(int, input().split(' '))))
k = int(input())
for (i, chapter) in enumerate(chapters):
	if k >= chapter[0] and k <= chapter[1]:
		print(n - i)


def ChapsUnread(n, page, chaps):
	for i in range(n):
		if page <= chaps[i][1]:
			return n - i
	return 0
n = int(input())
chaps = []
for i in range(n):
	temp = list(map(int, input().split()))
	chaps.append(temp)
page = int(input())
print(ChapsUnread(n, page, chaps))


n = int(input())
ar = [[int(i) for i in input().split()] for i in range(n)]
k = int(input())
if k == 0:
	print(n)
else:
	c = n
	for i in range(n):
		if k > ar[i][1]:
			c -= 1
	print(c)


def f(n, l_r_arr, k):
	now = 0
	for i in range(n):
		if l_r_arr[i][0] <= k <= l_r_arr[i][1]:
			now = i
			break
	return n - now
n = int(input())
l_r_arr = []
for i in range(n):
	l_r_arr.append(list(map(int, input().split())))
k = int(input())
print(f(n, l_r_arr, k))


c = 0
l1 = []
r1 = []
for i in range(int(input())):
	(l, r) = map(int, input().split())
	l1.append(l)
	r1.append(r)
k = int(input())
for i in r1:
	if k <= i:
		c += 1
print(c)


def Book(n, c, k):
	res = 0
	for i in range(n):
		if k in range(c[i][0], c[i][1] + 1):
			return n - i
n = int(input())
ch = []
for i in range(n):
	c = [int(n) for n in input().split()]
	ch.append(c)
k = int(input())
print(Book(n, ch, k))


n = int(input())
dp = [0 for i in range(11000)]
for i in range(n):
	(l, r) = map(int, input().split())
	dp[r] += 1
k = int(input())
for i in range(1, 10100):
	dp[i] += dp[i - 1]
print(n - dp[k - 1])


n = int(input())
d = []
for i in range(n):
	(a, b) = map(int, input().split())
	c = []
	for j in range(a, b + 1):
		c.append(j)
	d.append(c)
x = int(input())
k = 0
for i in range(n):
	if x in d[i]:
		break
print(n - i)


n = int(input())
z = []
for i in range(n):
	z.append(list(map(int, input().split())))
k = int(input())
f1 = False
for i in range(0, n):
	for j in range(0, 2):
		if k <= z[i][j]:
			f1 = True
			break
	if f1:
		break
print(n - i)


n = int(input())
arr = []
for _ in range(n):
	ar = [int(num) for num in input().split()]
	ar = [k for k in range(ar[0], ar[1] + 1)]
	arr.append(ar)
m = int(input())
for ar in arr:
	if m in ar:
		print(n - arr.index(ar))
		break


def solve():
	n = int(input())
	l = []
	for i in range(0, n):
		(a, b) = input().split()
		l.append(b)
	x = int(input())
	for i in range(0, n):
		if x <= int(l[i]):
			print(n - i)
			break
solve()


n = int(input())
chapitres = []
for aj in range(n):
	chapitres.append(list(map(int, input().split(' '))))
page = int(input())
for i in range(n):
	if page >= chapitres[i][0] and page <= chapitres[i][1]:
		print(n - i)
		break


n = int(input())
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(b)
x = int(input())
c = 0
for i in l:
	if x > i:
		c += 1
	else:
		break
print(n - c)


l = []
res = 0
c = int(input())
for i in range(c):
	nl = list(map(int, input().split()))
	l.append(nl[1])
q = int(input())
for i in l:
	if q <= i:
		res += 1
print(res)


import sys
n = int(input())
book = []
for i in range(n):
	inp = input().split()
	r = int(inp.pop(0))
	l = int(inp.pop(0))
	book.append((r, l))
k = int(input())
for i in range(n):
	if k >= book[i][0] and k <= book[i][1]:
		print(n - i)
		break


n = int(input())
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(y)
p = int(input())
for i in range(n):
	if p <= a[i]:
		print(n - i)
		break


(n, a) = (int(input()), [])
for i in range(n):
	b = [int(j) for j in input().split()]
	a.append(b)
(k, i) = (int(input()), 0)
while not a[i][0] <= k <= a[i][1]:
	i += 1
print(n - i)


n = int(input())
first = [-1] * n
last = [-1] * n
for i in range(n):
	(first[i], last[i]) = list(map(int, input().split()))
k = int(input())
for i in range(n):
	if k >= first[i] and k <= last[i]:
		print(n - i)
		break


n = int(input())
a = list()
for i in range(n):
	l = [int(i) for i in input().split()]
	a.append(l)
k = int(input())
for i in range(len(a)):
	for j in range(len(a[i]) - 1):
		if k >= a[i][j] and k <= a[i][j + 1]:
			print(n - i)
			break


n = int(input())
ans = 0
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	a.append(r)
a.append(10 ** 4)
k = int(input())
while a[ans] < k:
	ans += 1
print(n - ans)


n = int(input())
a = []
for i in range(n):
	(x, y) = list(map(int, input().split()))
	a.append((x, y))
k = int(input())
for (idx, val) in enumerate(a):
	if val[0] <= k <= val[1]:
		print(n - idx)
		break


n = int(input())
temp = []
for i in range(n):
	(l, r) = map(int, input().split())
	temp.append(list(range(l, r + 1)))
k = int(input())
for i in range(n):
	if k in temp[i]:
		print(n - i)
		break


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
k = int(input())
ans = 0
t = 0
f = 0
for i in range(n):
	if k == a[i][1]:
		t = i
		break
	if a[i][0] <= k < a[i][1]:
		t = i
		break
print(n - t)


inp = int(input().strip())
l = []
for i in range(inp):
	(a, b) = map(int, input().strip().split())
	l.append((a, b))
k = int(input().strip())
i = len(l)
for j in l:
	if k > j[1]:
		i -= 1
	else:
		break
print(i)


n = int(input())
record = {}
li = []
for i in range(n):
	(l, r) = map(int, input().split())
	li.append(l)
	record[l] = i + 1
k = int(input())
li.append(k)
li.sort()
for (i, v) in enumerate(li):
	if v == k:
		if i + 1 <= n and li[i + 1] == k:
			print(n - record[v] + 1)
		else:
			print(n - record[li[i - 1]] + 1)
		break


n = int(input())
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	a.append((l, r))
k = int(input())
c = 0
tof = False
for i in a:
	if tof:
		c += 1
	elif i[0] <= k and k <= i[1]:
		c = 1
		tof = True
print(c)


n = int(input())
chapters = []
while n > 0:
	(f, l) = map(int, input().split(' '))
	chapters.append([f, l])
	n -= 1
k = int(input())
count = 0
for i in chapters:
	if k <= i[1]:
		break
	else:
		count += 1
print(len(chapters) - count)


chapters = int(input())
pages = []
for i in range(chapters):
	pages.append([int(page) for page in input().split()])
markedPage = int(input())
for i in range(chapters):
	if markedPage >= pages[i][0] and markedPage <= pages[i][1]:
		print(chapters - i)
		break


n = int(input())
lr = [list(map(int, input().split())) for _ in range(n)]
k = int(input())
ans = n
for lri in lr:
	if lri[0] <= k <= lri[1]:
		print(ans)
		break
	else:
		ans -= 1


from sys import stdin
input = stdin.readline
n = int(input())
nums = [tuple(map(int, inp.split())) for inp in stdin.read().splitlines()]
t = nums[-1][0]
i = 0
while i < n:
	if t > nums[i][1]:
		i += 1
	else:
		break
print(n - i)


import sys
n = int(input())
blocks = []
for i in range(n):
	block = sys.stdin.readline().strip().split()
	blocks.append(int(block[1]))
k = int(input())
ans = n
for block in blocks:
	if block < k:
		ans -= 1
	else:
		break
print(ans)


n = int(input())
inp = []
for i in range(n):
	(l, r) = map(int, input().split())
	inp.append(r)
k = int(input())
for x in inp:
	if k > x:
		n -= 1
print(n)


i = input
a = [int(i().split()[1]) for j in [0] * int(i())]
k = int(i())
print(sum((x >= k for x in a)))


a = int(input())
s = []
for i in range(a):
	s.append([int(x) for x in input().split()])
x = int(input())
for (i, obj) in enumerate(s):
	if x in range(obj[0], obj[1] + 1):
		print(a - i)
		break


n = int(input())
p = []
for i in range(n):
	(a, b) = map(int, input().split())
	for j in range(a, b + 1):
		p.append(n - i)
print(p[int(input()) - 1])


n = int(input())
v = []
for _ in range(n):
	(a, b) = map(int, input().split())
	v.append(tuple((a, b)))
k = int(input())
for i in range(n):
	if k >= v[i][0] and k <= v[i][1]:
		idx = i
		break
print(n - idx)


n = int(input())
chapter_border = []
for i in range(n):
	chapter_border.append(list(map(int, input().split())))
current_page = int(input())
current_chapter = [start <= current_page <= end for (start, end) in chapter_border]
print(n - current_chapter.index(True))


n = int(input())
l = []
r = []
for i in range(n):
	(x, y) = list(map(int, input().split()))
	l.append(x)
	r.append(y)
k = int(input())
a = 0
for i in range(len(r)):
	if k <= r[i]:
		a = len(r) - i
		break
print(a)


a = []
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	a.append([l, r])
k = int(input())
for i in range(len(a)):
	if k in range(a[i][0], a[i][1] + 1):
		print(len(a) - i)
		break


a = int(input())
li = []
for i in range(a):
	(b, c) = map(int, input().split())
	li.append(c)
d = int(input())
c = 0
for i in li:
	if i + 1 > d:
		break
	else:
		c += 1
print(a - c)


n = int(input())
a = []
b = []
rn = n
while n > 0:
	s = input()
	r = 0
	for i in s:
		if i == ' ':
			a.append(r)
			r = 0
		else:
			r = r * 10 + int(i)
	b.append(r)
	n -= 1
k = int(input())
cur = 0
fl = 0
for i in range(0, rn):
	if a[i] <= k and k <= b[i]:
		fl = 1
		print(rn - cur)
		break
	cur += 1
if fl == 0:
	print(0)


num_tcs = int(input())
chaps = []
for k in range(0, num_tcs):
	x = input().strip().split()
	p = []
	p.append(int(x[0]))
	p.append(int(x[1]))
	chaps.append(p)
page_num = int(input())
count = 0
for x in chaps:
	if page_num in range(x[0], x[1] + 1):
		break
	count = count + 1
print(len(chaps) - count)


n = int(input())
(lst, m) = ([list(map(int, input().split())) for _ in range(n)], int(input()))
print(sum((x[0] <= m <= x[1] or m <= x[1] for x in lst)))


def res():
	n = int(input())
	a = []
	for l in range(n):
		(i, j) = map(int, input().split())
		a.append([i, j])
	k = int(input())
	for i in range(len(a)):
		if a[i][0] <= k and a[i][1] >= k:
			print(n - i)
			break
res()


l = []
t = int(input())
while t > 0:
	(x, y) = list(map(int, input().split()))
	l.append(y)
	t = t - 1
z = int(input())
i = 0
while i < len(l):
	if l[i] > z - 1:
		break
	else:
		i = i + 1
print(len(l) - i)


n = int(input().strip())
a = []
for i in range(n):
	(l, r) = map(int, input().strip().split())
	a.append(r)
k = int(input().strip())
count = 0
for aa in a:
	if k <= aa:
		break
	count += 1
print(len(a) - count)


n = int(input())
i = 0
chapters = []
while i < n:
	borders = ([int(a) for a in input().split()], n - i)
	chapters.append(borders)
	i += 1
mark = int(input())
for item in chapters:
	if item[0][0] <= mark <= item[0][1]:
		print(item[1])
		break


n = int(input())
a = [[]]
for i in range(n):
	a.append([0, 0])
	a[i] = input().split()
k = int(input())
for i in range(n):
	if k >= int(a[i][0]) and k <= int(a[i][1]):
		z = i
print(n - z)


n = int(input())
li = []
for i in range(n):
	(a, b) = map(int, input().split())
	li.append(a)
	li.append(b)
m = int(input())
count = 0
for i in range(0, len(li), 2):
	if m <= li[i + 1]:
		count += 1
print(count)


count = int(input())
sections = [list(map(int, input().split())) for x in range(count)]
num = int(input())
for x in range(count):
	if num >= sections[x][0] and num <= sections[x][1]:
		print(count - x)
		break


n = int(input())
chapters = []
for i in range(n):
	ab = [int(x) for x in input().strip().split(' ')]
	chapter = (ab[0], ab[1])
	chapters.append(chapter)
k = int(input())
for i in range(1, n + 1):
	chapter = chapters[i - 1]
	if chapter[0] <= k and k <= chapter[1]:
		ans = n - i + 1
print(ans)


import sys
n = int(input())
LR = [list(map(int, input().split())) for i in range(n)]
k = int(input())
for i in range(n):
	(l, r) = LR[i]
	if k > r:
		continue
	if k <= r:
		print(n - i)
		sys.exit()


n = int(input())
l = []
for _ in range(n):
	l.append(list(map(int, input().split())))
k = int(input())
count = 0
for i in range(n):
	if k <= l[i][1]:
		break
	count += 1
print(n - count)


n = int(input())
cnt = 0
l = [0] * n
r = [0] * n
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
k = int(input())
for i in range(n):
	if k <= r[i]:
		cnt += 1
print(cnt)


z = []
count = 0
n = int(input())
for x in range(n):
	l = list(map(int, input().strip().split()[:2]))
	z.append(l)
	if x == n - 1:
		k = int(input())
for y in range(n):
	if z[y][0] <= k and k <= z[y][1]:
		print(n - count)
		break
	else:
		count += 1


n = int(input())
tmp = []
for i in range(n):
	tmp.append([int(x) for x in input().split(' ')])
k = int(input())
for i in range(n):
	if tmp[i][0] <= k <= tmp[i][1]:
		print(n - i)


INF = 100000000
t = 1
for test in range(t):
	n = int(input())
	arr = []
	for i in range(n):
		(l, r) = map(int, input().split())
		arr.append(r - l + 1)
	k = int(input())
	read = 0
	for i in range(k):
		if arr[read] == 0:
			read += 1
		arr[read] -= 1
	print(n - read)


n = int(input())
l1 = []
if n == 1:
	print(1)
else:
	for i in range(n):
		(l, r) = map(int, input().split())
		l1.append(l)
	j = 0
	f = 0
	k = int(input())
	while f == 0:
		if j + 1 == n:
			f = 1
		elif l1[j] <= k < l1[j + 1]:
			f = 1
		j += 1
	print(n - (j - 1))


n = int(input())
chapter = []
for i in range(n):
	chapter.append(list(map(int, input().split())))
k = int(input())
for i in range(n):
	if k <= chapter[i][1]:
		print(n - i)
		break


n = int(input())
start = []
end = []
for i in range(n):
	(a, b) = map(int, input().split())
	start.append(a)
	end.append(b)
k = int(input())
for i in range(n):
	if k in range(start[i], end[i] + 1):
		break
print(n - i)


from sys import stdin, stdout
from math import sqrt, pi, acos, gcd, atan2, cos, sin, factorial
from decimal import Decimal
PEPS = 1e-10
INF = float('inf')

def sqr(a):
	return a * a

def dist(a, b=(0, 0)):
	return sqrt(sqr(a[0] - b[0]) + sqr(a[1] - b[1]))

def s_dist(a, b=(0, 0)):
	return sqr(a[0] - b[0]) + sqr(a[1] - b[1])

def dist3(a, b=(0, 0, 0)):
	return sqrt(sqr(a[0] - b[0]) + sqr(a[1] - b[1]) + sqr(a[2] - b[2]))

def s_dist3(a, b=(0, 0, 0)):
	return sqr(a[0] - b[0]) + sqr(a[1] - b[1]) + sqr(a[2] - b[2])

def trans(p, al):
	return (p[0] * cos(al) + p[1] * sin(al), -p[0] * sin(al) + p[1] * cos(al))

def get_angle(a, b, c):
	cos_al = (sqr(a) + sqr(b) - sqr(c)) / (2 * a * b)
	return acos(cos_al)

def write_float(ans):
	stdout.write(str('%.6f' % ans) + '\n')

def get_hight(pt1, pt2, pt3):
	a = (pt2[0] - pt1[0], pt2[1] - pt1[1])
	b = (pt3[0] - pt1[0], pt3[1] - pt1[1])
	return abs(a[0] * b[1] - a[1] * b[0]) / dist(pt1, pt2)

def get_square(pt1, pt2, pt3):
	a = (pt2[0] - pt1[0], pt2[1] - pt1[1])
	b = (pt3[0] - pt2[0], pt3[1] - pt2[1])
	return (a[0] * b[-1] - a[1] * b[0]) / 2

def sign(v):
	if v > 0:
		return 1
	elif v < 0:
		return -1
	else:
		return 0

def inn(pt, triangle):
	signs = set()
	signs.add(sign(get_square(triangle[0], triangle[1], pt)))
	signs.add(sign(get_square(triangle[1], triangle[2], pt)))
	signs.add(sign(get_square(triangle[2], triangle[0], pt)))
	return len(signs) == 1

def inter_in(a, b):
	return dist((a[0], a[1]), (b[0], b[1])) < a[-1] + b[-1]

def inter_in3(a, b):
	return dist3(a[:-1], b[:-1]) < a[-1] + b[-1]

def shift(what, wth):
	return (what[0] - wth[0], what[1] - wth[1])
n = int(stdin.readline())
chal = []
for i in range(n):
	(l, r) = map(int, stdin.readline().split())
	chal.append((l, r))
k = int(stdin.readline())
ans = 0
for p in chal:
	if p[1] >= k:
		ans += 1
stdout.write(str(ans))


no = int(input())
arr = []
for i in range(no):
	a = list(map(int, input().split()))
	arr.append(a)
nn = int(input())
count = 0
for i in arr:
	if nn <= i[1]:
		break
	else:
		count += 1
print(no - count)


n = int(input())
capitulos = [0] * 100 * 100 + [0]
for capitulo in range(n):
	(inicio, fim) = [int(c) for c in input().split()]
	for pagina in range(inicio, fim):
		capitulos[pagina] = capitulo
	capitulos[fim] = capitulo
pagina_atual = int(input())
print(n - capitulos[pagina_atual])


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


n = int(input())
page = []
for i in range(n):
	(m, k) = map(int, input().split())
	page.append((m, k))
h = int(input())
for i in range(n):
	if h <= page[i][1]:
		print(n - i)
		break


ch = []
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ch.append([a, b])
k = int(input())
c = 0
for i in ch:
	if i[0] >= k or i[1] >= k:
		c += 1
print(c)


n = int(input())
list_in = []
for i in range(n):
	a = [int(x) for x in input().split()]
	list_in.append(a)
k = int(input())
index = 0
while k - 1 >= list_in[index][1] and index < n:
	index += 1
print(n - index)


t = int(input())
lst = []
for i in range(0, t):
	(a, b) = map(int, input().split())
	lst.append([a, b])
left = int(input())
i = 0
while True:
	if lst[i][0] <= left <= lst[i][1]:
		print(len(lst) - i)
		break
	else:
		i += 1


n = int(input())
a = [int(input().split()[0]) for i in range(n)]
k = int(input())
print(n - sum((k >= a[i] for i in range(1, len(a)))))


loops = int(input())
inputs = []
for x in range(loops):
	inputs.append(input().split())
last_page = int(input())

def fun():
	for i in range(len(inputs)):
		if last_page <= int(inputs[i][1]):
			print(len(inputs) - i)
			return 0
fun()


n = int(input())
book = []
for _ in range(n):
	book.append(list(map(int, input().split(' '))))
page = int(input())
res = n
for chapter in book:
	if chapter[0] <= page and page <= chapter[1]:
		break
	else:
		res -= 1
print(res)


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
l = []
for i in range(n):
	l.append(I())
(k,) = I()
for (j, i) in enumerate(l):
	if k >= i[0] and k <= i[1]:
		print(n - j)
		break


n = int(input())
l = []
for i in range(n):
	l.append([int(x) for x in input().split()])
k = int(input())
for i in range(n):
	if l[i][1] >= k >= l[i][0]:
		print(n - i)
		break


n = int(input())
m = n
a = []
b = []
for i in range(n):
	a = input().split()
	b.append(int(a[1]))
k = int(input())
for i in range(n):
	if k <= b[i]:
		print(m)
		break
	m -= 1


chapters = int(input())
pages = []
for i in range(chapters):
	pages.append(list(map(int, input().split())))
page = int(input())
for completed in range(chapters):
	(l, r) = pages[completed]
	if page <= r:
		print(chapters - completed)
		break


def getIntList(lst):
	assert type(lst) is list
	rep = []
	for i in lst:
		rep.append(int(i))
	return rep
n = int(input())
mark = []
for i in range(0, n):
	mark.append(getIntList(input().split(' '))[1])
latest = int(input())
import bisect
ans = bisect.bisect_left(mark, latest)
print(n - ans)


n = int(input())
f = []
for i in range(n):
	(a, b) = map(int, input().split())
	f.append(a)
	f.append(b)
k = int(input())
k = k - 1
z = 0
for i in range(1, len(f), 2):
	if f[i] <= k:
		z = z + 1
print(n - z)


n = int(input())
chp_start = []
chp_end = []
for i in range(0, n):
	(l, r) = map(int, input().split(' '))
	chp_start.append(l)
	chp_end.append(r)
k = int(input())
count = 0
for i in range(0, n):
	if k >= chp_start[i] and k <= chp_end[i]:
		count = i
		break
print(n - count)


n = int(input())
b = []
for i in range(n):
	a = input().split()[1]
	b.append(int(a))
m = int(input())
p = n
for i in b:
	if m > i:
		p -= 1
print(p)


s = 0
data = []
number = int(input())
for a in range(number):
	(t, tem_data) = map(int, input().split())
	data.append(tem_data)
last_page = int(input())
for b in range(number):
	if last_page <= data[b]:
		s = b
		break
print(number - s)


n = int(input())
lk = []
for i in range(n):
	(l, j) = map(int, input().split())
	lk.append(l)
	lk.append(j)
k = int(input())
(lo, hi) = (0, len(lk))
while lo < hi:
	mid = (lo + hi) // 2
	if lk[mid] > k:
		hi = mid
	else:
		lo = mid + 1
if lo % 2 == 0:
	print(n - lo // 2 + 1)
else:
	print(n - lo // 2)


def ans(arr):
	cnt = 0
	for i in range(n):
		if k >= arr[i][0] and k <= arr[i][1]:
			break
		cnt += 1
	return n - cnt
n = int(input())
temp = []
for _ in range(n):
	temp.append(list(map(int, input().strip().split())))
k = int(input())
print(ans(temp))


n = int(input())
l1 = []
for i in range(n):
	m = list(map(int, input().split()))
	l1.append(m)
n1 = int(input())
for i in range(n):
	if n1 >= l1[i][0] and n1 <= l1[i][1]:
		a = n - i
print(a)


from sys import *
n = int(stdin.readline())
a = []
for i in range(n):
	x = list(map(int, stdin.readline().split()))
	a.append(x)
k = int(input())
b = [0] * (a[n - 1][1] + 1)
l = j = 0
for i in range(a[n - 1][1] + 1):
	if i > a[j][1]:
		l += 1
		j += 1
	b[i] = l
print(n - b[k])


def max1(a):
	p = a[0]
	for x in a:
		if x > p:
			p = x
	return p

def preobr(x):
	if x % 2 == 1:
		return x + 1
	else:
		return x - 1

def prlist(a):
	for x in a:
		print(x, end=' ')

def dlin(n):
	k = 0
	while n > 0:
		n -= k
		k += 1
	return k - 1
n = int(input())
p = n
a = []
for i in range(n):
	b = list(map(int, input().split()))
	a.append(b)
k = int(input())
for i in range(n):
	if a[i][1] < k:
		p -= 1
print(p)


import sys
chapters = int(sys.stdin.readline().strip())
chapter_pages = list()
for i in range(1, chapters + 1):
	(l, r) = sys.stdin.readline().split()
	chapter_pages.append((l, r))
read_page = int(sys.stdin.readline().strip())
for (index, chapter) in enumerate(chapter_pages):
	if int(chapter[0]) <= read_page <= int(chapter[1]):
		print(chapters - index)
		break
else:
	print(1)


n = int(input())
rec = []
for i in range(n):
	(a, b) = map(int, input().split())
	rec.append((a, b))
k = int(input())
for i in range(n):
	(a, b) = rec[i]
	if a <= k <= b:
		print(n - i)
		break


num_of_chaps = int(input())
chapters = []
for i in range(num_of_chaps):
	chapters.append(input().split())
last_page = int(input())
count = 1
for p in chapters:
	if int(p[0]) <= last_page <= int(p[1]):
		break
	else:
		count += 1
print(len(chapters) + 1 - count)


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


import getpass
import math
import sys
import string
import re
import math
import random
from decimal import Decimal, getcontext

def ria():
	return [int(i) for i in input().split()]
if getpass.getuser() != 'frohenk':
	filename = 'half'
else:
	sys.stdin = open('input.txt')
n = ria()[0]
ar = []
for i in range(n):
	ar.append(ria())
lk = ria()[0]
cnt = 0
lk -= 1
for (l, r) in ar:
	if l <= lk and r <= lk:
		cnt += 1
print(n - cnt)


a = int(input())
p = 0
k = []
for i in range(a):
	k.append([int(i) for i in input().split()])
	k[i] = range(k[i][0], k[i][1] + 1)
b = int(input())
for i in range(a):
	if k[i].count(b) != 0:
		p = i
print(a - p)


from bisect import *
chap = int(input())
ar = []
for c in range(chap):
	(s, e) = map(int, input().split())
	ar += [e]
k = int(input())
print(chap - bisect_left(ar, k))


n = int(input())
a = [[0 for x in range(2)] for y in range(n)]
for i in range(n):
	(a[i][0], a[i][1]) = map(int, input().split())
k = int(input())
count = 0
for i in range(n):
	if a[i][1] >= k:
		break
	count += 1
print(n - count)


n = int(input())
lst = []
for i in range(n):
	lst.append([])
N = n
i = 0
while n > 0:
	(f, e) = input().split()
	f = int(f)
	e = int(e)
	lst[i].append(f)
	lst[i].append(e)
	i += 1
	n -= 1
k = int(input())
for ele in lst:
	if k >= ele[0] and k < ele[1]:
		ind = lst.index(ele)
		pos = len(lst) - ind
		break
	elif k == ele[1]:
		ind = lst.index(ele)
		pos = len(lst) - ind
print(pos)


import sys
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
n = int(input())
l = []
for _ in range(n):
	(a, b) = map(int, input().split())
	l.append(b)
k = int(input())
c = 0
for i in range(n):
	if k <= l[i]:
		break
	else:
		c += 1
print(n - c)


n = int(input())
a = []
for i in range(n):
	x = list(map(int, input().split()))
	a.append(x)
k = int(input())
for j in range(len(a)):
	if k <= a[j][1]:
		print(n - j)
		break


import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

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

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

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

def string_list():
	return list(input())

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

def binaryToDecimal(n):
	return int(n, 2)

def solve():
	n = int(input())
	chapter = []
	for _ in range(n):
		chapter.append(list_input())
	k = int(input())
	for i in range(n):
		if chapter[i][0] <= k and chapter[i][1] >= k:
			print(n - i)
			return
	print(0)
t = 1
for _ in range(t):
	solve()


n = int(input())
c = 0
li = []
ri = []
for i in range(1, n + 1, 1):
	(l, r) = input().split()
	li.append(int(l))
	ri.append(int(r))
k = int(input())
out = len(ri)
for i in range(0, n, 1):
	if ri[i] < k:
		c += 1
print(out - c)


ch = int(input())
s = []
for i in range(ch):
	x = input().split()
	s.append(int(x[1]))
page = int(input())
chapter = 0
for i in range(ch):
	if page > s[i]:
		chapter += 1
print(ch - chapter)


n = int(input())
s = []
for i in range(0, n):
	a = list(map(int, input().split()))
	s.append(a[1])
p = int(input())
s.append(p)
s.sort()
print(n - s.index(p))


def answer():
	a = int(input())
	c = []
	while a:
		d = input().split()
		d = [int(x) for x in d]
		c.append(d)
		a -= 1
	i = 0
	read = int(input())
	while i < len(c):
		if c[i][0] <= read and read <= c[i][1]:
			print(len(c) - i)
			break
		i += 1
answer()


n = int(input())
x = []
for i in range(n):
	(a, l) = map(int, input().split())
	x.append([a, l])
d = int(input())
t = n
for i in range(n):
	if d <= x[i][1]:
		break
	else:
		t -= 1
print(t)


import sys
import math
import bisect

def main():
	n = int(input())
	A = []
	for i in range(n):
		A.append(list(map(int, input().split())))
	k = int(input())
	ans = 0
	for i in range(n):
		if k - 1 < A[i][1]:
			ans += 1
	print(ans)
main()


import sys
import math
from statistics import mean
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
li = []
for i in range(n):
	(x, y) = invr()
	li.append(y)
k = inp()
c = 0
for j in range(n):
	if k > li[j]:
		c = c + 1
print(n - c)


n = int(input())
ends = []
for i in range(n):
	ends.append(int(input().split()[1]))
k = int(input())
i = 0
while i < n and ends[i] < k:
	i += 1
print(n - i)


T = int(input())
ls = []
for i in range(T):
	(a, b) = map(int, input().split())
	ls.append((a, b))
k = int(input())
for tup in ls:
	if tup[0] <= k <= tup[1]:
		i = tup
		break
print(T - ls.index(i))


n = int(input())
mat = []
for _ in range(n):
	(i, j) = map(int, input().split())
	mat.append(j + 1)
z = int(input())
for x in range(n):
	if mat[x] > z:
		break
print(n - x)


ts = int(input())
lst = []
for _ in range(ts):
	res = []
	(a, b) = map(int, input().split())
	res.append(a)
	res.append(b)
	lst.append(res)
n = int(input())
for i in range(ts):
	if lst[i][0] <= n <= lst[i][1]:
		print(ts - i)
		break


n = int(input())
right = []
for i in range(n):
	(l, r) = map(int, input().split())
	right.append(r)
k = int(input())
print(sum([k <= r for r in right]))


n = int(input())
l = []
for _ in range(n):
	(le, r) = map(int, input().split())
	l.append(r)
cnt = 0
page = int(input())
for i in l:
	if page > i:
		cnt += 1
print(n - cnt)


chapters = int(input())
chapter_pages = []
for i in range(chapters):
	chapter_pages.append(list(map(int, input().split())))
page_index = int(input())
chapter = 0
i = 0
stop = False
while not stop:
	if page_index >= chapter_pages[i][0] and page_index <= chapter_pages[i][1]:
		chapter = i
		stop = True
	i += 1
print(len(chapter_pages) - chapter)


n = int(input())
l = []
while n:
	n -= 1
	(a, b) = map(int, input().strip().split(' '))
	l.append((a, b))
n = int(input())
l.sort()
for i in range(len(l)):
	if n > l[i][1]:
		continue
	elif n <= l[i][1]:
		count = len(l) - i
		break
print(count)


n1 = int(input())
cnt = 0
g = 0
l = []
for i in range(n1):
	(n, m) = map(int, input().split())
	l.append(m)
k = int(input())
for i in range(len(l)):
	if l[i] < k:
		cnt += 1
print(n1 - cnt)


n = int(input())
chapters = [tuple(map(int, input().split())) for i in range(n)]
k = int(input())
c = n - 1
found = False
while c >= 0 and (not found):
	found = chapters[c][0] <= k
	c -= 1
c += 1
print(n - c)


n = int(input())
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append([a, b])
l.sort()
k = int(input())
flag = 0
for i in range(n):
	(a, b) = l[i]
	if a <= k <= b:
		flag = 1
		break
if flag == 1:
	print(n - i)
else:
	print(0)


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
k = int(input())
ans = n
for i in range(n):
	if a[i][0] <= k - 1 < a[i][1]:
		ans = n - i
	elif a[i][1] == k - 1:
		ans = n - i - 1
print(ans)


n = int(input())
check = []
for i in range(n):
	(a, b) = map(int, input().split())
	check.append(b)
k = int(input())
for i in check:
	if k > i:
		n -= 1
print(n)


n = int(input())
A = [map(int, input().split()) for i in range(n)]
k = int(input())
ans = 0
for i in range(n):
	(l, r) = A[i]
	if k <= r:
		ans += 1
print(ans)


n = int(input())
chapters = []
for n in range(n):
	chapters.append([int(x) for x in input().split(' ')])
page = int(input())
i = 0
while i <= n:
	if chapters[i][1] >= page:
		break
	i += 1
print(str(n - i + 1))


k = int(input())
pages = [list(map(int, input().split())) for i in range(k)]
lastpage = int(input())
for i in range(k):
	if pages[i][0] <= lastpage <= pages[i][1]:
		k -= i
print(k)


n = int(input())
chapters = [tuple(map(int, input().split())) for _ in range(n)]
k = int(input())
for (i, (_, r)) in enumerate(chapters):
	if k <= r:
		print(n - i)
		break


n = int(input())
li = []
for i in range(n):
	k = list(map(int, input().split()))
	for j in k:
		li.append(j)
s = int(input())
c = 0
for f in li:
	if f >= s:
		break
	else:
		c += 1
t = len(li) - c
if t % 2 == 0:
	print(t // 2)
else:
	print(t // 2 + 1)


import sys
import bisect
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))
n = ini()
chap = []
for _ in range(n):
	(a, b) = inm()
	chap.append(a)
	chap.append(b)
index = ini()
x = bisect.bisect_left(chap, index)
print(n - x // 2)


n = int(input())
lst = []
for i in range(n):
	(m1, m) = map(int, input().split())
	lst.append(m)
mar = int(input())
cnt = 0
for i in lst:
	if mar > i:
		cnt = cnt + 1
print(n - cnt)


import bisect
n = int(input())
a = []
for i in range(n):
	(l, b) = list(map(int, input().split()))
	a.append((l, b))
k = int(input())
for i in range(len(a)):
	if a[i][0] <= k <= a[i][1]:
		print(n - i)
		break


n = int(input())
x = []
y = []
for i in range(1, n + 1):
	(l, r) = map(int, input().split())
	x.append(l)
	y.append(r)
k = int(input())
c = 0
for i in range(n):
	if k <= y[i]:
		c = c + 1
print(c)


n = int(input())
l = []
for _ in range(n):
	l1 = list(map(int, input().split()))
	l.append(l1)
np = int(input())
rch = n
for i in range(n):
	for j in l:
		if np >= j[0] and np <= j[1]:
			print(rch)
			exit()
		else:
			rch -= 1


n = int(input())
l = []
for i in range(n):
	(a, b) = map(int, input().split(' '))
	l += [i + 1] * (b - a + 1)
print(n - l[int(input()) - 1] + 1)


a = int(input())
b = []
for i in range(a):
	c = list(map(int, input().split()))
	b.append(c)
k = int(input())
for j in range(a):
	t = b[j]
	if t[0] <= k and t[1] >= k:
		print(a - j)
		break


n = int(input())
l = []
for i in range(n):
	a = list(map(int, input().split()))
	l.append(a)
k = int(input())
count = 0
ind = 0
for i in range(len(l)):
	for j in range(2):
		if k == l[i][j]:
			if j == 0 or j == 1:
				count = n - i
		if k > l[i][0] and k < l[i][1]:
			count = n - i
print(count)


n = int(input())
d = []
for i in range(n):
	(a, b) = list(map(int, input().split()))
	d.append(b)
k = int(input())
for i in range(n):
	if d[i] >= k:
		print(n - i)
		break


def main():
	n = int(input())
	(l, r) = ([0 for i in range(n)], [0 for i in range(n)])
	i = 0
	tc = n
	while tc:
		(l[i], r[i]) = map(int, input().split())
		i += 1
		tc -= 1
	k = int(input())
	ans = 0
	for i in range(n):
		if l[i] <= k <= r[i]:
			ans = i
			break
	print(n - ans)
main()


n = int(input())
ans = n
items = []
while n:
	n -= 1
	(a, b) = map(int, input().split())
	items.append(b)
mx = int(input())
for item in items:
	if item < mx:
		ans -= 1
	else:
		break
print(ans)


def readLine():
	a = input()
	return [int(i) for i in a.split(' ')]
n = readLine()[0]
a = [readLine()[1] for _ in range(n)]
k = readLine()[0]
ans = 0
for (i, val) in enumerate(a):
	if val >= k:
		ans = n - i
		break
print(ans)


a = []
for b in range(int(input())):
	a.append([int(i) for i in input().split()] + [b])
p = int(input())
for i in a:
	if i[0] <= p <= i[1]:
		print(len(a) - i[2])
		exit()


t = int(input())
lst = []
for c in range(t):
	lst.append(list(map(int, input().split()))[1])
k = int(input())
count = 0
for c in range(t):
	if lst[c] < k:
		count += 1
print(t - count)


n = int(input())
t = list()
for i in range(n):
	(a, b) = map(int, input().split())
	t.append(a)
	t.append(b)
s = int(input())
for i in range(len(t)):
	if s <= t[i]:
		k = i
		break
print(n - k // 2)


def main():
	n = int(input())
	pars = list()
	for i in range(n):
		(l, r) = map(int, input().split())
		pars.append((l, r))
	k = int(input())
	for i in range(n):
		if pars[i][0] <= k <= pars[i][1]:
			if k - 1 == pars[i][1]:
				print(n - i + 1)
				return 0
			print(n - i)
			return 0
main()


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
t = int(input())
r = []
for _ in range(t):
	r.append(map(int, stdin.readline().split()))
k = int(input())
ans = 0
for (i, j) in r:
	if k <= j:
		break
	ans += 1
print(t - ans)


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
n = int(input())
chapters = []
for _ in range(n):
	(l, r) = map(int, input().split())
	chapters.append((l, r))
k = int(input())
ind = 0
for i in range(n):
	if k <= chapters[i][1]:
		ind = i
		break
print(n - ind)


arr = []
for i in range(int(input())):
	(n, m) = map(int, input().split())
	arr.append(range(n, m + 1))
k = int(input())
count = 0
for i in arr:
	count += 1
	if k in i:
		break
print(len(arr) - count + 1)


n = int(input())
(l, r) = ([], [])
for _ in range(n):
	(x, y) = input().split()
	l.append(int(x))
	r.append(int(y))
k = int(input())
ind = 0
while r[ind] < k:
	ind += 1
print(n - ind)


n = int(input())
ps = []
for _ in range(n):
	ps.append(list(map(int, input().split())))
k = int(input())
import bisect
print(n - bisect.bisect_left([g[1] for g in ps], k))


l = []
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(b)
k = int(input())
l.append(k)
q = len(l)
for i in range(q - 1):
	if l[i] >= k:
		print(q - i - 1)
		exit()


n = input()
s = []
lst = []
for x in range(0, int(n)):
	s.append(input())
	lst.append(s[x].split())
k = input()
for x in range(0, int(n)):
	if int(lst[x][0]) <= int(k) & int(k) <= int(lst[x][1]):
		print(int(n) - int(x))
		break


x = int(input())
y = []
a = 0
for i in range(x):
	y.append(list(map(int, input().split(' '))))
z = int(input()) - 1
for i in y:
	if z >= i[1]:
		a += 1
	else:
		pass
print(x - a)


n = int(input())
a = []
for i in range(n):
	(ta, tb) = map(int, input().split())
	a.append([ta, tb])
k = int(input())
for i in range(n):
	if a[i][0] <= k <= a[i][1]:
		print(n - i)
		break


n = int(input())
arr = []
for i in range(n):
	(x, y) = map(int, input().split())
	arr.append([x, y])
ans = 0
k = int(input())
index = -1
k -= 1
for i in range(len(arr)):
	if arr[i][0] <= k and k >= arr[i][1]:
		index = i
print(n - index - 1)


n = int(input())
book = []
for _ in range(n):
	book.append([int(_) for _ in input().split()])
k = int(input())
for (i, (l, r)) in enumerate(book):
	if l <= k <= r:
		print(len(book) - i)
		break


n = int(input())
A = []
for i in range(n):
	(l, r) = map(int, input().split())
	A.append([l, r])
c = int(input())
ans = 0
for i in range(n):
	if c >= A[i][0] and c <= A[i][1]:
		ans = i
		break
print(n - ans)


n = int(input())
d = []
while n > 0:
	(l, r) = map(int, input().split())
	n -= 1
	z = [l, r]
	d.append(z)
m = int(input())
a = 0
for i in range(len(d)):
	d1 = d[i][0]
	d2 = d[i][1]
	if (m >= d1 or m <= d2) and m <= d2:
		a += 1
print(a)


import math
n = int(input())
d = []
for x in range(n):
	a = [int(q) for q in input().strip().split()]
	d.append(a)
t = int(input())
for x in range(n):
	if t >= d[x][0] and t <= d[x][1]:
		print(n - x)


m = []
k = int(input())
for i in range(k):
	m.extend([list(map(int, list(input().split())))])
n = int(input())
for i in range(len(m)):
	if m[i][1] >= n:
		k = i
		break
print(len(m) - k)


n = int(input())
d = []
for _ in range(n):
	(l, r) = [int(item) for item in input().split()]
	d.append([l, r])
k = int(input())
ans = 0
for i in range(n):
	(l, r) = d[i]
	if r >= k:
		ans = i
		break
print(n - ans)


n = int(input())
arr = []
for x in range(n):
	(a, b) = map(int, input().split())
	arr.append([a, b])
k = int(input())
c = 0
for x in arr:
	a = x[0]
	b = x[1]
	if k > a and k > b:
		pass
	else:
		c += 1
print(c)


n = int(input())
I = []
for i in range(n):
	k = list(map(int, input().split()))
	I.append(k)
N = int(input())

def chapters_left(n, I, N):
	if N <= I[0][1]:
		return n
	main = []
	for i in range(len(I)):
		l = list(range(I[i][0], I[i][1] + 1))
		main.append(l)
	for i in range(len(main)):
		if N in main[i]:
			return n - i
	return 0
print(chapters_left(n, I, N))


n = int(input(''))
s = [list(map(int, input().split())) for i in range(n)]
k = int(input('')) - 1
j = -1
for i in range(n):
	if s[i][0] <= k and s[i][1] > k:
		j = i
	elif s[i][1] == k:
		j = i + 1
if j == -1:
	print(n)
else:
	print(n - j)


total_chp = int(input())
book = []
for i in range(0, total_chp):
	chp = input().split(' ')
	book.append(int(chp[1]))
mark_page = int(input())
read_chp = 0
for end_chp in book:
	if mark_page > end_chp:
		read_chp += 1
	else:
		break
print(len(book) - read_chp)


n = int(input())
chapters = []
for i in range(n):
	chapter = input().split(' ')
	chapters.append([int(chapter[0]), int(chapter[1])])
k = int(input())
chapter_to_read = n
chapter_have_read = 0
for i in range(len(chapters)):
	chapter = chapters[i]
	if k > chapter[1]:
		chapter_have_read = chapter_have_read + 1
print(n - chapter_have_read)


n = int(input())
chapters = []
count = 0
for i in range(n):
	(begin, end) = input().split()
	begin = int(begin)
	end = int(end)
	chapter = [begin, end]
	chapters.append(chapter)
k = int(input())
for ch in chapters:
	if k >= ch[0] and k <= ch[1]:
		print(len(chapters) - count)
		break
	count += 1


n = int(input())
end_pages = []
s = 0
e = 0
for i in range(n):
	(s, e) = map(int, input().split())
	end_pages.append(e)
k = int(input())
print(sum((1 for i in end_pages if k <= i)))


n = int(input())
x = []
for i in range(n):
	x.append(list(map(int, input().split())))
k = int(input())
t = False
i += 1
if k == 0:
	print(n)
elif k > x[-1][-1]:
	print(0)
else:
	for i in range(len(x)):
		if k in range(x[i][0], x[i][1] + 1):
			print(n - i)
			break


n = int(input())
m = n
chapters = []
while m > 0:
	interval = str(input())
	chapters.append(int(interval.split()[1]))
	m -= 1
unread_page = int(input())
for each in chapters:
	if each >= unread_page:
		answer = n - chapters.index(each)
		break
print(answer)


I = lambda : map(int, input().split())
n = int(input())
l = []
for _ in range(n):
	(x, y) = I()
	l = l + [[x, y]]
t = int(input())
for i in range(1, n + 1):
	l1 = l[i - 1]
	(x, y) = (l1[0], l1[1])
	if x <= t <= y:
		break
print(n - i + 1)


chap = int(input())
ls = []
for _ in range(chap):
	ls.append(list(map(int, input().split())))
ind = int(input())
i = 0
while i < chap:
	if ls[i][1] >= ind:
		break
	i += 1
print(chap - i)


n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
k = int(input()) - 1
cnt = 0
for el in arr:
	if el[1] <= k:
		cnt += 1
print(n - cnt)


n = int(input())
a = []
for _ in range(n):
	(l, r) = map(int, input().split())
	a.append(r)
a.append(10 ** 8)
k = int(input()) - 1
res = 0
for i in a:
	if k < i:
		print(n - res)
		break
	res += 1


def solve():
	n = int(input())
	chapters = []
	for i in range(n):
		temp = input().split(' ')
		chapters.append(temp[1])
	k = int(input())
	for j in chapters:
		if k <= int(j):
			print(n - chapters.index(j))
			break
solve()


def g():
	n = int(input())
	l = list()
	for _ in range(n):
		l.append(int(input().lstrip('0123456789').lstrip()))
	x = int(input())
	for i in range(n):
		if x <= l[i]:
			print(n - i)
			break
g()


ce = list()
c = int(input())
for _ in range(c):
	ce.append(int(input().split()[1]))
k = int(input())
if c == 1:
	print(1)
else:
	print(sum((1 for i in ce if i >= k)))


n = int(input())
result = {}
count = 0
for i in range(n):
	k = input().split(' ')
	result[int(k[0])] = int(k[1])
l = int(input())
for i in result:
	if l > i and l > result[i]:
		count += 1
print(n - count)


n = int(input())
a = []
b = []
for i in range(0, n):
	(a_i, b_i) = map(int, input().split(' '))
	a.append(a_i)
	b.append(b_i)
r = int(input())
for i in b:
	if r <= i:
		print(n - b.index(i))
		break


n = int(input())
a = [tuple(map(int, input().split())) for i in range(n)]
x = int(input())
i = 0
while i != len(a) and a[i][1] < x:
	i += 1
print(len(a) - i)


p = []
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	p.append(b)
k = int(input())
for i in range(len(p)):
	if k <= p[i]:
		print(n - i)
		break


n = int(input())
c = []
for i in range(n):
	a = input()
	c.append(a)
k = int(input())
for i in c:
	(a, b) = i.split()
	a = int(a)
	b = int(b)
	if k >= a and k <= b:
		h = c.index(i)
		ans = n - h
		print(ans)


n = int(input())
a = []
for i in range(0, n):
	x = input().split(' ')
	a.append((int(x[0]), int(x[1])))
x = int(input())
for i in range(0, len(a)):
	if x >= a[i][0] and x <= a[i][1]:
		print(len(a) - i)
		break


a = []
cnt = 0
n = int(input())
for i in range(n):
	(l, r) = [int(x) for x in input().split()]
	a.append([l, r])
k = int(input())
d = k - 1
a.sort()
for i in range(n):
	if k > a[i][1]:
		cnt += 1
	else:
		break
print(n - cnt)


try:
	n = int(input())
	chapter = []
	for each in range(0, n):
		s = list(map(int, input().split()))
		chapter.append(s)
	chapter_not_read = 0
	k = int(input())
	count = n
	for each in chapter:
		count -= 1
		if each[1] >= k:
			chapter_not_read = count + 1
			break
	print(chapter_not_read)
except:
	pass


a = []
n = int(input())
for x in range(n):
	c = list(map(int, input().split()))
	a.append(c)
k = int(input())
s = 0
for x in range(n):
	if a[x][0] <= k <= a[x][1]:
		s += 1
	elif a[x][0] > k:
		s += 1
print(s)


test = int(input())
l = []
for _ in range(test):
	l.append(list(map(int, input().split())))
page = int(input())
count = 0
for i in range(test):
	if page <= l[i][1]:
		count = test - i
		break
print(count)


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
import heapq
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = ri(1)
ans = 0
m = []
for i in range(n):
	m.append(ri())
k = ri(1)
for i in range(n):
	if m[i][0] <= k and m[i][1] >= k:
		ans = i
print(n - ans)


n = int(input())
chapters = list()
for _ in range(n):
	chapter = tuple(map(int, input().split()))
	chapters.append(chapter)
page = int(input())
for i in range(len(chapters)):
	(l, r) = chapters[i]
	if l <= page <= r:
		break
print(n - i)


n = int(input())
lr = []
for i in range(n):
	lr.append([int(c) for c in input().split()])
k = int(input())
(i, kq) = (0, 0)
while i < n and kq == 0:
	if k <= lr[i][1]:
		kq = n - i
	i = i + 1
print(kq)


l = []
n = int(input())
for u in range(n):
	l.append(list(map(int, input().split())))
k = int(input())
f = 0
for i in range(n):
	if k >= l[i][0] and k <= l[i][1]:
		print(n - i)
		f = 1
		break
if f == 0:
	print(0)


n = int(input())
a = [map(int, input().split()) for i in range(n)]
k = int(input())
s = 0
for i in range(n):
	(l, r) = a[i]
	if l > k:
		break
	s += 1
print(n - s + 1)


n = int(input())
l1 = []
for i in range(n):
	l = list(map(int, input().split()))
	l1.append(l)
x = int(input())
for i in range(len(l1)):
	if l1[i][1] >= x:
		print(n - i)
		break


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
DIRECTIONS = [[0, 1], [0, -1], [1, 0], [1, -1]]
NEIGHBOURS = [(i, j) for i in range(-1, 2) for j in range(-1, 2) if i != 0 or j != 0]
OrdUnicode_a = ord('a')
OrdUnicode_A = ord('A')
CAPS_ALPHABETS = {chr(i + OrdUnicode_A): i for i in range(26)}
SMOL_ALPHABETS = {chr(i + OrdUnicode_a): i for i in range(26)}
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0) + 1
INFINITY = float('inf')
n = int(input())
li = []
for i in range(n):
	(a, b) = get_ints()
	li.append(b)
k = int(input())
from bisect import bisect_left
pos = bisect_left(li, k)
print(n - pos)


n = int(input())
arr = []
for i in range(n):
	(a, b) = map(int, input().split())
	arr.append(b)
x = int(input())
count = 0
for i in arr:
	if i + 1 > x:
		break
	count += 1
print(n - count)


n = int(input())
chapters = []
for i in range(n):
	(a, b) = map(int, input().split())
	chapters.append([a, b])
not_read = int(input())
first = 0
last = len(chapters) - 1
while first <= last:
	middle = (first + last) // 2
	(a, b) = chapters[middle]
	if a <= not_read <= b:
		print(len(chapters) - middle)
		break
	if not_read < a:
		last = middle - 1
	else:
		first = middle + 1


import sys
n = int(input())
l = []
for i in range(n):
	(l1, r1) = list(map(int, input().split()))
	l.append(range(l1, r1 + 1))
k = int(input())
count = 0
for i in range(n):
	if k not in l[i]:
		count += 1
	else:
		print(n - count)
		sys.exit()
print(n - count)


x = int(input())
z = []
for i in range(x):
	a = list(map(int, input().split()))
	z.append(a)
y = int(input())
for i in range(x):
	if z[i][0] <= y and z[i][1] >= y:
		print(x - i)
		break


n = int(input())
t = []
for i in range(1, n + 1):
	t.append(list(map(int, input().split())))
p = int(input())
to = 0
for g in t:
	if p > g[1]:
		pass
	else:
		to += 1
print(to)


n = int(input())
z = []
for i in range(n):
	(a, b) = map(int, input().split())
	z.append(b)
k = int(input())
for i in z:
	if k <= i:
		break
	else:
		n -= 1
print(n)


n = int(input())
d = [0] * 10005
for i in range(n):
	(a, b) = map(int, input().split())
	for j in range(a, b + 1):
		d[j] = i
c = int(input())
print(n - d[c])


from sys import stdin, stdout
n = int(stdin.readline())
chapters = []
for i in range(n):
	chapter = tuple(map(int, stdin.readline().split()))
	chapters.append(chapter)
k = int(stdin.readline())
current = -1
for (i, chapter) in enumerate(chapters):
	(l, r) = chapter
	if l <= k and k <= r:
		current = i
		break
stdout.write('{}\n'.format(n - current))


t = int(input())
start = [0 for i in range(t)]
e = [0 for i in range(t)]
for i in range(t):
	[a, m] = list(map(int, input().split()))
	start[i] = a
	e[i] = m
k = int(input())
for i in range(t):
	if start[i] <= k and e[i] >= k:
		check = i
		break
print(t - check)


list1 = []
for i in range(int(input())):
	list1.append([*map(int, input().split())][0])
a = int(input())
b = len(list1)
c = 0
for j in range(b):
	if a < list1[j]:
		c = 1
		print(b - j + 1)
		break
if c == 0:
	print('1')


from sys import stdin, stdout

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

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

def linp():
	return list(minp())

def main():
	n = inp()
	l = []
	for i in range(n):
		(x, y) = minp()
		l.append([x, y])
	p = inp()
	pos = 0
	for i in range(n):
		if p >= l[i][0] and p <= l[i][1]:
			pos = n - i
			break
	print(pos)
main()


m = int(input())
a = []
for _ in range(m):
	a.append(list(map(int, input().split())))
n = int(input())
count = 0
for (l, r) in a:
	if n >= l and n <= r:
		print(m - count)
		break
	elif n > r:
		count += 1


n = int(input())
m = []
for i in range(n):
	li = list(map(int, input().split()))
	m.append(li)
d = int(input())
for i in range(n):
	if d <= max(m[i]):
		print(n - i)
		break
	else:
		continue


n = int(input())
l = []
c = 0
for i in range(n):
	(li, ri) = map(int, input().split())
	l.append(ri)
k = int(input())
for i in l:
	if k <= i:
		c += 1
print(c)


n = int(input())
L = []
while n:
	(l, r) = map(int, input().split())
	L.append((l, r))
	n = n - 1
k = int(input())
c = 0
for i in range(len(L)):
	if L[i][0] >= k or L[i][1] >= k:
		c += 1
print(c)


n = int(input())
arr = []
for _ in range(n):
	a = tuple(map(int, input().split(' ')))
	arr.append(a)
c = int(input())
ch = 0
for tup in arr:
	if c <= tup[1]:
		break
	ch += 1
print(n - ch)


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


n = int(input())
c = []
for i in range(n):
	(a, b) = map(int, input().split())
	c.append(b)
p = int(input())
for i in range(n):
	if c[i] >= p:
		break
print(n - i)


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


f = []
n = int(input())
for item in range(n):
	(b, e) = list(map(int, input().split()))
	f.append(e)
k = int(input())
count = n
for item in f:
	if k > item:
		count = count - 1
print(count)


n = int(input())
ls = []
for i in range(n):
	ls.append(list(map(int, input().split())))
p = int(input())
for i in ls:
	if i[1] >= p:
		break
print(n - ls.index(i))


n = int(input())
t = []
for i in range(n):
	(x, y) = [int(x) for x in input().split()]
	t += [y]
r = int(input())

def s():
	for i in range(n):
		if t[i] >= r:
			print(n - i)
			return
	print(0)
s()


t = int(input())
a = []
count = 0
for z in range(t):
	(n, m) = map(int, input().split())
	a.append(n)
	a.append(m)
k = int(input())
for i in a:
	if i > k:
		count += 1
print(count // 2 + 1)


q = int(input())
w = []
for i in range(q):
	e = list(map(int, input().split()))
	w.append(e)
r = int(input())
for i in range(q):
	if w[i][0] <= r and w[i][1] >= r:
		print(q - i)
		break


a = int(input())
b = []
for x in range(a):
	b.append(list(map(int, input().split())))
c = int(input())
for i in range(a):
	for j in range(b[i][0], b[i][1] + 1):
		d = []
		d.append(j)
		if c in d:
			print(a - i)


import sys, math, queue
sys.setrecursionlimit(1000000)
n = int(input())
l = [-1 for i in range(n)]
r = [-1 for i in range(n)]
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
k = int(input())
for i in range(n):
	if k >= l[i] and k <= r[i]:
		print(n - i)
		exit(0)


n = int(input())
intervals = []
for i in range(n):
	(l, r) = map(int, input().split())
	intervals.append([l, r])
k = int(input())
beg = 0
end = n - 1
remain = 0
while beg <= end:
	mid = int((end + beg) / 2)
	if k >= intervals[mid][0] and k <= intervals[mid][1]:
		remain = n - mid
		break
	elif k < intervals[mid][0]:
		end = mid - 1
	else:
		beg = mid + 1
print(remain)


t = int(input())
end = []
for x in range(t):
	chap = input()
	(l, r) = chap.split()
	end.append(int(r))
k = int(input())
comp = 0
for x in range(t):
	if k > end[x]:
		comp += 1
	else:
		break
print(t - comp)


n = int(input())
l = [0] * n
r = [0] * n
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
k = int(input())
ctr = 0
for i in r:
	if i >= k:
		break
	else:
		ctr += 1
print(n - ctr)


n = int(input())
li = []
c = 0
for i in range(n):
	t = tuple(map(int, input().split()))
	li.append(t)
k = int(input())
for i in li:
	if i[0] <= k <= i[1]:
		break
	else:
		c = c + 1
print(n - c)


l = {}
n = int(input())
for i in range(n):
	l[i] = list(map(int, input().split()))
a = int(input())
for i in range(len(l)):
	if a > l[i][1]:
		n -= 1
print(n)


def book(n):
	l = []
	c = 0
	for i in range(n):
		ind = list(map(int, input().split()))
		l.append(ind)
	k = int(input())
	for i in l:
		if k - 1 >= i[1]:
			c += 1
	return len(l) - c
n = int(input())
print(book(n))


chapters = int(input())
pages = []
for _ in range(chapters):
	page = list(map(int, input().split()))
	pages.append(page)
k = int(input())
for (a, b) in pages:
	if k in range(a, b + 1):
		flag = pages.index([a, b])
		break
print(chapters - flag)


chapters_number = int(input())
chapter_list = []
for i in range(chapters_number):
	chapter_list.append([int(x) for x in input().split(' ')])
bookmark = int(input())
for (i, chapter) in enumerate(chapter_list):
	if chapter[0] <= bookmark <= chapter[1]:
		print(chapters_number - i)
		break


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

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

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
a = []
for i in range(n):
	a.append(value())
k = Int()
ans = n
for (l, r) in a:
	if l <= k <= r:
		break
	ans -= 1
print(ans)


n = int(input())
m = []
need = 0
for i in range(n):
	m.append([int(x) for x in input().split()])
s = int(input())
counter = 0
for i in m:
	counter += 1
	if s in list(range(i[0], i[1] + 1)):
		need += counter
print(len(m) - need + 1)


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


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


chap = int(input())
book = []
for i in range(chap):
	book.append(tuple(map(int, input().split())))
ques = int(input())
for i in book:
	if i[1] < ques:
		chap = chap - 1
	else:
		print(chap)
		break


n = int(input())
num = []
for i in range(n):
	(i, j) = map(int, input().split())
	num.append(j)
k = int(input()) - 1
ans = 0
while num[ans] <= k:
	ans += 1
print(n - ans)


def main():
	n = int(input())
	chp = []
	for i in range(n):
		t = [int(x) for x in input().split()]
		chp.append((t[0], t[1]))
	k = int(input())
	a = 0
	for (x, y) in chp:
		if k <= y:
			ans = len(chp) - a
			break
		else:
			a += 1
	print(ans)
main()


def nasty_read_book():
	n = int(input())
	pages = list()
	for i in range(n):
		(a, b) = map(int, input().split(sep=' '))
		pages.append(a)
	current_page = int(input())
	for i in range(n - 1):
		if pages[i] <= current_page < pages[i + 1]:
			print(len(pages) - i)
			break
	else:
		print(1)
nasty_read_book()


n = int(input())
a = []
b = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
q = int(input())
for i in range(n):
	if q >= a[i] and q <= b[i]:
		print(n - i)


hop = []
for i in range(int(input())):
	(a, b) = map(int, input().split())
	hop.append(b)
k = int(input())
for i in range(len(hop)):
	if k <= hop[i]:
		print(len(hop) - i)
		break


list2 = []
n = int(input())
for i in range(n):
	(l, r) = input().split(' ')
	(l, r) = [int(l), int(r)]
	list2.append(r)
k = int(input())
count = 0
for i in range(n):
	if k > list2[i]:
		count = count + 1
print(n - count)


n = int(input())
ll = [0] * (101 * n)
for i in range(n):
	(l, r) = map(int, input().split())
	for j in range(l, r + 1):
		ll[j] = i + 1
k = int(input())
print(n - ll[k] + 1)


n = int(input())
l = []
r = []
for i in range(n):
	(l1, r1) = map(int, input().split())
	l.append(l1)
	r.append(r1)
k = int(input())
i = 0
while k > r[i]:
	i += 1
print(n - i)


n = int(input())
L = []
for _ in range(n):
	(a, b) = [int(x) for x in input().split()]
	L.append((a, b))
k = int(input()) - 1
p = False
for i in range(n):
	if k < L[i][1]:
		break
else:
	print(0)
	p = True
if not p:
	print(n - i)


n = int(input())
pg = []
for _ in range(n):
	pg.append([int(x) for x in input().split()])
k = int(input())
i = 0
for i in range(n):
	if k <= pg[i][1]:
		break
print(n - i)


flag = False
counter_chapters = 0
list_all = [list(map(int, input().split())) for i in range(int(input()))]
k = int(input())
for (not_read, read) in list_all:
	if not flag:
		if k in [i for i in range(not_read, read + 1)]:
			flag = True
			counter_chapters += 1
	else:
		counter_chapters += 1
print(counter_chapters)


n = int(input())
res = []
for i in range(n):
	res.append(list(map(int, input().split())))
k = int(input())
for i in range(len(res)):
	if max(res[i]) >= k:
		break
print(len(res) - i)


n = int(input())
li = []
for i in range(0, n):
	li.append(input().split())
a = int(input())
c = 1
for i in range(n - 1, -1, -1):
	if a < int(li[i][0]):
		c += 1
	else:
		break
print(c)


t = int(input())
arr = []
for i in range(t):
	arr.extend(map(int, input().split()))
n = int(input())
idx = 0
for i in range(len(arr)):
	if arr[i] >= n:
		idx = i
		break
idx = idx // 2
print(t - idx)


n = int(input())
book = []
for i in range(n):
	(l, r) = map(int, input().split())
	book.append([l, r])
k = int(input())
for i in book:
	if k >= i[0] and k <= i[1]:
		print(n - book.index(i))
		break


x = int(input())
l = [list(map(int, input().split())) for i in range(x)]
k = int(input())
for i in range(x):
	for j in range(1):
		a = l[i][j]
		b = l[i][j + 1]
		for t in range(a, b + 1):
			if t == k:
				m = i
				break
print(x - m)


n = int(input())
arr = [0] * n
for i in range(n):
	[data, x] = list(map(int, input().split()))
	arr[i] = x
k = int(input())
for i in range(n):
	if arr[i] >= k:
		print(n - i)
		break
else:
	if k < arr[-1]:
		print(1)
	else:
		print(0)


n = int(input())
rest = n
chapter = [0]
for _ in range(n):
	chapter.append(tuple(map(int, input().split())))
now = int(input())
for (l, r) in chapter[1:]:
	if l <= now <= r:
		break
	else:
		rest -= 1
print(rest)


n = int(input())
arr = []
for _ in range(n):
	arr.append(list(map(int, input().split())))
val = int(input())
num = n
for i in range(n):
	if arr[i][0] <= val and val <= arr[i][1]:
		num = i
		break
print(n - num)


x = int(input())
L = []
for i in range(x):
	L.append(list(map(int, input().split())))
y = int(input())
count = 0
for i in range(x):
	if y <= L[i][1] and y >= L[i][0]:
		count = i
		break
print(x - count)


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
x = int(input())
for i in range(n):
	if x > a[i][1]:
		continue
	else:
		break
print(n - i)


n = int(input())
arr = []
for _ in range(n):
	arr.append(list(map(int, input().split())))
k = int(input())
c = 0
for i in range(n):
	if arr[i][1] < k:
		c += 1
	else:
		break
print(n - c)


mi = lambda : [int(i) for i in input().split()]
n = int(input())
dat = [mi() for _ in range(n)]
k = int(input())
readed = 0
for i in dat:
	(l, r) = i
	if l <= k and r >= k:
		print(n - readed)
		exit()
	readed += 1
print(n)


n = int(input())
l = [[y for y in range(*[int(x) if j == 0 else int(x) + 1 for (j, x) in enumerate(input().split())])] for i in range(n)]
q = int(input())
print(n - [i for (i, x) in enumerate(l) if q in x][0])


from itertools import *
n = int(input())
a = [y - x + 1 for (x, y) in (map(int, input().split()) for _ in [0] * n)]
k = int(input())
print(n - next((i for (i, p) in enumerate(accumulate(a)) if p >= k), n))


n = int(input())
res = []
for i in range(n):
	(l, r) = [int(x) for x in input().split()]
	res.append([l, r])
k = int(input())
for j in range(n):
	if k >= res[j][0] and k <= res[j][1]:
		break
print(n - j)


count = 0
n = int(input())
l = []
for i in range(n):
	p = list(map(int, input().split()))
	l.append(p)
m = int(input())
for j in range(len(l)):
	if l[j][0] <= m and l[j][1] >= m:
		n = n - j
print(n)


n = int(input())
l = []
r = []
for i in range(n):
	t = input().split()
	l.append(t[0])
	r.append(t[1])
k = int(input())
for i in range(n):
	if k >= int(l[i]) and k <= int(r[i]):
		print(n - i)


nchapters = int(input())
chapters = [tuple(map(int, input().split())) for _ in range(nchapters)]
p = int(input())
for i in range(nchapters):
	if p in range(chapters[i][0], chapters[i][1] + 1):
		print(nchapters - i)
		break


a = [int(input().split()[1]) for _ in range(int(input()))]
k = int(input())
print(sum((x >= k for x in a)))


qtd = int(input())
ultimaspaginas = []
for i in range(qtd):
	(p, u) = list(map(int, input().split()))
	ultimaspaginas.append(u)
atual = int(input())
capnlidos = len(ultimaspaginas)
for x in ultimaspaginas:
	if atual <= x:
		print(capnlidos)
		break
	else:
		capnlidos -= 1


def go():
	n = int(input())
	books = []
	for i in range(n):
		books.append([int(i) for i in input().split(' ')][1])
	k = int(input())
	read = 0
	for i in range(n):
		if books[i] >= k:
			return n - read
		read += 1
print(go())


n = int(input())
start_pages = []
s = 0
e = 0
for i in range(n):
	(s, e) = map(int, input().split())
	start_pages.append(s)
start_pages.append(e + 1)
start_pages.append(100 * 100 + 1)
k = int(input())
for i in range(len(start_pages) - 1):
	if start_pages[i] <= k < start_pages[i + 1]:
		print(n - i)


n = int(input())
l = []
for _ in range(n):
	l.append(tuple(map(int, input().split())))
k = int(input())
c = 0
for i in l:
	c += 1
	if i[0] <= k <= i[1]:
		print(n - c + 1)
		break
else:
	print(0)


import heapq
import sys
from collections import defaultdict, Counter
from functools import reduce
n = int(input())
arr = []
for i in range(n):
	(s, f) = list(map(int, input().split()))
	arr.append(f)
k = int(input())
f = arr[0]
ans = 0
while k > f:
	ans += 1
	f = arr[ans]
print(n - ans)


n = int(input())
l1 = []
l2 = []
for i in range(n):
	(a, b) = map(int, input().split())
	l1.append(a)
	l2.append(b)
k = int(input())
t = 0
for i in range(n):
	if l2[i] < k:
		t += 1
print(n - t)


n = int(input())
li = []
ri = []
for i in range(n):
	(l, r) = map(int, input().split(' '))
	li.append(l)
	ri.append(r)
k = int(input())
ans = 1
for i in range(n):
	if li[i] > k:
		ans = n - i + 1
		break
	elif li[i] == k:
		ans = n - i
print(ans)


def main():
	n = int(input())
	chapters = []
	for i in range(n):
		(l, r) = map(int, input().split())
		chapters.append((l, r))
	k = int(input())
	rem = 0
	index = -1
	for i in range(n):
		if index == -1:
			if chapters[i][0] <= k <= chapters[i][1]:
				index = i
				break
	print(n - index)
main()


n = int(input())
nums = []
for _ in range(n):
	nums.append(list(map(int, input().split())))
k = int(input())
i = 0
while i < n and k >= nums[i][0]:
	i += 1
print(n - i + 1)


n = int(input())
dic = dict()
for i in range(n):
	(r, l) = list(map(int, input().split()))
	dic[l] = r
p = int(input())
for (i, d) in enumerate(dic):
	if dic[d] <= p and p <= d:
		break
print(n - i)


import sys
import collections
input = sys.stdin.readline

def printnl(val):
	sys.stdout.write(str(val) + '\n')
n = int(input())
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	a += [(l, r)]
k = int(input())
for i in range(n):
	if k >= a[i][0] and k <= a[i][1]:
		print(n - i)


n = int(input())
a = []
b = []
for i in range(n):
	y = input().split()
	x = y[0]
	a.append(int(x))
	y = y[1]
	b.append(int(y))
p = int(input())
ans = 0
for i in range(n):
	if p > b[i]:
		ans = ans + 1
		continue
print(n - ans)


n = int(input())
lis = []
for i in range(n):
	(a, b) = map(int, input().split())
	lis.append([a, b])
lis.sort()
c = 0
k = int(input())
for i in range(n):
	if lis[i][0] <= k and lis[i][1] >= k:
		c = i
		break
print(n - c)


n = int(input())
lri = [list(map(int, input().split())) for i in range(n)]
k = int(input())
ans = n
for i in range(n):
	if k <= lri[i][1]:
		break
	ans -= 1
print(ans)


t = int(input())
l = []
for k in range(t):
	(a, b) = map(int, input().split())
	l.append(a)
	l.append(b)
n = int(input())
c = 0
for i in range(2 * t):
	if l[i] >= n:
		if (2 * t - i) % 2 == 0:
			c = (2 * t - i) // 2
		else:
			c = (2 * t - i) // 2 + 1
		break
print(c)


import array as arr
n = int(input())
for j in range(0, n):
	a = [0] * n
for j in range(0, n):
	a[j] = list(map(int, input().split()))
s = int(input())
for j in range(0, n, 1):
	if s >= a[j][0] and s <= a[j][1]:
		break
print(n - j)


n = int(input())
l = []
r = []
for i in range(n):
	[ln, rn] = [int(x) for x in input().split()]
	l.append(ln)
	r.append(rn)
k = int(input())
i = 0
while k > l[i] and k > r[i]:
	i += 1
print(n - i)


n = int(input())
count = n
chapters = []
for i in range(n):
	x = input().split()
	x = x[1]
	chapters.append(int(x))
k = int(input())
for i in chapters:
	if k > i:
		count -= 1
	else:
		break
print(count)


noc = int(input())
li = []
for i in range(noc):
	(f, l) = [int(x) for x in input().split()]
	li.append(f)
	li.append(l)
c = 0
ind = 0
indi = 0
key = int(input())
for i in range(0, len(li), 2):
	ind += 1
	for j in range(li[i], li[i + 1] + 1):
		if j == key:
			indi = 1
			break
	if indi == 1:
		break
c += len(li) // 2 - ind + 1
print(c)


t = int(input())
l1 = []
for i in range(t):
	(fp, lp) = map(int, input().split())
	l1.append(lp)
pagel = int(input())
for i in l1:
	if pagel <= i:
		temp = l1.index(i)
		break
ans = len(l1) - temp
print(ans)


def range_from_str_range(string):
	(l, r) = map(int, string.split())
	return set(range(l, r + 1))
q = int(input())
book = [range_from_str_range(input()) for _ in range(q)]
k = int(input())
for (chapter_number, pages) in enumerate(book):
	if k in pages:
		print(q - chapter_number)
		break


n = int(input())
book = []
for i in range(0, n):
	(s, e) = map(int, input().split())
	book.append((s, e))
k = int(input())
for i in range(n):
	if book[i][0] <= k and book[i][1] >= k:
		break
print(n - i)


x = int(input())
y = [list(map(int, input().split())) for c in range(x)]
index = int(input())
for c in range(x):
	if index >= y[c][0] and index <= y[c][1]:
		print(len(y) - c)
		break


import bisect
n = int(input())
ar = list()
for i in range(n):
	(l, r) = map(int, input().split())
	ar.append(r)
k = int(input()) - 1
pos = bisect.bisect(ar, k)
print(n - pos)


n = int(input())
l = [list(map(int, input().split()))[0] for i in range(n - 1)]
(ll, rr) = map(int, input().split())
l.append(ll)
l.append(rr + 1)
k = int(input())
for i in range(n + 1):
	if l[i] > k:
		print(n - i + 1)
		break
else:
	print(0)


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
nb_chapters = RI()
done = 0
pages = {}
for _ in range(nb_chapters):
	(s, e) = RMI()
	for i in range(s, e + 1):
		pages[i] = pages.get(i, 0) + done
	done += 1
curr = int(input())
print(nb_chapters - pages[curr])


n = int(input())
x = []
for i in range(n):
	(l, r) = map(int, input().split())
	x.append(r)
c = 0
k = int(input())
for i in range(len(x)):
	if k <= x[i]:
		c += len(x) - i
		break
print(c)


n = int(input())
L = list()
R = list()
for _ in range(0, n):
	(l, r) = map(int, input().split())
	L.append(l)
	R.append(r)
k = int(input())
for i in range(0, n):
	if k <= R[i]:
		break
ans = n - i
print(ans)


t = int(input())
z = t
l = []
while t != 0:
	t -= 1
	(l1, r) = [int(i) for i in input().split()]
	l.append(r)
k = int(input())
for x in l:
	if k <= x:
		y = l.index(x)
		break
print(z - y)


n = int(input())
b = []
for i in range(n):
	(f, l) = list(map(int, input().split()))
	a = []
	for i in range(f, l + 1):
		a.append(i)
	b.append(a)
m = int(input())
for i in range(len(b)):
	if m in b[i]:
		break
print(len(b) - i)


from sys import stdin, stdout, exit as sys_ret
(f_input, f_print, f_flush) = (stdin.readline, stdout.write, stdout.flush)
toms = int(f_input())
book = [[int(i) for i in f_input().split()] for _ in range(toms)]
page = int(f_input())
tom = 0
for i in range(toms):
	if page >= book[i][0] and page <= book[i][1]:
		tom = i + 1
		break
f_print(str(toms - tom + 1))


import math
n = int(input())
ans = n
last = []
for i in range(n):
	(a, b) = input().split()
	last.append(int(b))
k = int(input())
for i in range(len(last)):
	if last[i] < k:
		ans -= 1
print(ans)


a = int(input())
num = {}
for i in range(a):
	num[i] = list(map(int, input().split()))
b = int(input())
for i in range(a):
	if b >= num[i][0] and b <= num[i][1]:
		print(a - i)


from bisect import bisect_left
n = int(input())
a = [None] * n
for i in range(n):
	a[i] = int(input().split()[-1])
b = int(input())
print(n - bisect_left(a, b))


pages = []
for _ in range(int(input())):
	pages.append(list(map(int, input().split())))
n = int(input())
for i in range(len(pages)):
	if pages[i][0] <= n <= pages[i][1]:
		print(len(pages) - i)
		break


n = int(input())
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	a += [(l, r)]
k = int(input())
count = 0
for (l, r) in a:
	if not r < k:
		count += 1
print(count)


n = int(input())
l = []
r = []
for i in range(n):
	(l1, r1) = map(int, input().split())
	l.append(l1)
	r.append(r1)
k = int(input())
res = 1
for el in l:
	if k < el:
		res += 1
print(res)


a = int(input())
d = []
for _ in range(a):
	(b, c) = map(int, input().split())
	d.append(c)
k = int(input())
j = int(0)
for x in d:
	if x < k:
		j = j + 1
	else:
		break
print(a - j)


n = int(input())
cnt = 0
chapters = []
for i in range(n):
	(x, y) = map(int, input().split())
	chapters.append([x, y])
k = int(input())
for seq in chapters:
	if k >= seq[0] and k <= seq[-1]:
		break
	else:
		cnt += 1
print(n - cnt)


n = int(input())
idx___f = []
idx___l = []
for _ in range(n):
	(f, l) = (int(x) for x in input().split())
	idx___f.append(f)
	idx___l.append(l)
next = int(input())
curr = next - 1
for (i, x) in enumerate(idx___l):
	if curr < x:
		print(n - i)
		quit()


from bisect import bisect_left

def bSearch(ll, n):
	return bisect_left(ll, n)
n = int(input())
chapters = []
for nn in range(0, n):
	(start, end) = map(int, input().split(' '))
	chapters.append(end)
page = int(input())
current_chapter = bSearch(chapters, page)
print(len(chapters) - current_chapter)


chapters = int(input())
ends = []
for i in range(chapters):
	(start, finish) = list(map(int, input().split()))
	ends.append(finish)
last = int(input())
for i in range(len(ends)):
	if last <= ends[i]:
		print(chapters - i)
		break
	if i == len(ends) - 1:
		print(0)


import math
n = int(input())
arr = []
for i in range(n):
	arr.append([int(i) for i in input().split()])
read = int(input())
for i in range(n):
	if read <= arr[i][1]:
		print(n - i)
		break


n = int(input())
b = [i for i in range(0, n)]
for i in range(0, n):
	b[i] = list(map(int, input().split()))
t = int(input())
for i in range(0, n):
	if t <= b[i][1] and t >= b[i][0]:
		print(n - i)


def main():
	n = int(input())
	parts_end = []
	for _ in range(n):
		part = input().split()[1]
		parts_end.append(int(part))
	k = int(input())
	for i in range(len(parts_end)):
		if k <= parts_end[i]:
			print(n - i)
			break
main()


from operator import itemgetter
n = int(input())
arr = [0] * n
for i in range(n):
	arr[i] = list(map(int, input().split()))
k = int(input())
arr = sorted(arr, key=itemgetter(0))
for i in range(n):
	if arr[i][0] <= k and arr[i][1] >= k:
		print(n - i)
		exit()
print(0)


def main():
	n = int(input())
	(l, r) = ([], [])
	for i in range(n):
		(a, b) = map(int, input().split())
		l.append(a)
		r.append(b)
	k = int(input())
	ans = 0
	for i in range(n):
		if l[i] <= k <= r[i]:
			ans = n - i
			break
	print(ans)
main()


c = 0
e = []
w = 0
n = int(input())
for i in range(n):
	d = [int(i) for i in input().split()]
	e.append(d)
r = int(input())
for i in e[:-1]:
	if i[0] <= r <= i[1]:
		w = n - c
	else:
		c += 1
if w != 0:
	print(w)
else:
	print('1')


n = int(input())
g = [tuple((int(t) for t in input().split(' '))) for _ in range(n)]
k = int(input())
i = 0
while i < n and g[i][1] < k:
	i += 1
print(n - i)


n = int(input())
s1 = []
s2 = []
for i in range(n):
	[a, b] = input().split(' ')
	s1.append(int(a))
	s2.append(int(b))
k = int(input())
for i in range(n):
	if k >= s1[i] and k <= s2[i]:
		x = i + 1
		break
print(n - x + 1)


n = int(input())
bk = []
for i in range(n):
	(l, r) = map(int, input().split())
	bk.append([l, r])
k = int(input())
total = 0
for i in bk:
	if i[1] >= k:
		total += 1
print(total)


import math
n = int(input())
chapters = []
for __ in range(n):
	(a, b) = [int(i) for i in input().split()]
	chapters.append(a)
	chapters.append(b)
pag = int(input())
if pag == 1:
	print(n)
else:
	for i in range(len(chapters)):
		if chapters[i] >= pag:
			if i % 2 == 0:
				print(n - i // 2)
			else:
				print(n - math.ceil(i / 2) + 1)
			break


ls = []
for i in range(int(input())):
	ls.append([*map(int, input().split())])
n = int(input())
ans = 0
for i in ls:
	ans += 1
	if i[0] <= n <= i[1]:
		print(len(ls) - ans + 1)


(n, res) = (int(input()), [])
for i in range(n):
	res.append([int(i) for i in input().split()])
k = int(input())
for i in res:
	if i[0] <= k <= i[1]:
		print(n - res.index(i))


n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]
k = int(input())
c = 0
for (l, r) in a:
	if l <= k <= r or l > k:
		c += 1
print(c)


n = int(input())
tail = []
for i in range(n):
	(a, b) = map(int, input().split())
	tail.append(b)
m = int(input())
for i in range(m):
	if m <= tail[i]:
		print(n - i)
		break


p = int(input())
c = []
count = 0
d = 0
for i in range(p):
	A = list(map(int, input().split()))
	c.append(A)
n = int(input())
for j in range(p):
	if c[j][0] <= n <= c[j][1]:
		count = count + 1
for k in range(p):
	if n > c[k][1]:
		d = d + 1
print(p - count + 1 - d)


n = int(input())
last_page = []
while n > 0:
	n -= 1
	(_, l) = list(map(int, input().split()))
	last_page.append(l)
k = int(input())
for i in range(len(last_page)):
	if k <= last_page[i]:
		print(len(last_page) - i)
		break


N = int(input())
Chapters = list()
for i in range(N):
	Chapters.append(list(map(int, input().split()))[1])
X = int(input())
i = 0
while Chapters[i] < X:
	i += 1
print(N - i)


N = int(input())
chapter = []
for i in range(N):
	(l, r) = map(int, input().split())
	chapter.append(r)
k = int(input())
for i in range(N):
	if chapter[i] < k:
		N -= 1
print(N)


n = int(input())
l = []
for i in range(0, n):
	l.append(list(map(int, input().split())))
v = int(input())
i = 0
while i < n:
	if v > l[i][1]:
		i += 1
	else:
		break
print(n - i)


import sys
import heapq
import math
from enum import Enum
lines = sys.stdin.read().splitlines()
n = int(lines[0])
pairs = []
for i in range(0, n):
	(l, r) = map(int, lines[i + 1].split(' '))
	pairs.append((l, r))
k = int(lines[n + 1])
count = n
for (l, r) in pairs:
	if k > r:
		count -= 1
print(count)


t = int(input())
pages = []
ind = 0
for i in range(t):
	(l, r) = map(int, input().split())
	if ind != 0:
		pages.append(pages[ind - 1] + r - l + 1)
	else:
		pages.append(r - l + 1)
	ind += 1
k = int(input())
k -= 1
count = 0
for i in range(t):
	if k >= pages[i]:
		count += 1
	else:
		break
print(t - count)


n = int(input())
m = [[0] * 2 for i in range(n)]
for i in range(0, n):
	(l, r) = map(int, input().split())
	m[i][0] = l
	m[i][1] = r
k = int(input())
for j in range(n - 1, -1, -1):
	if m[j][0] <= k:
		print(n - j)
		break


n = int(input())
page = []
for _ in range(n):
	(a, b) = map(int, input().split())
	page.append(b)
count = 0
k = int(input())
for i in page:
	if k <= i:
		count += 1
print(count)


n = int(input())
chapters = []
for _ in range(n):
	chapters.append(list(map(int, input().split())))
k = int(input())
for i in range(len(chapters)):
	if k >= chapters[i][0] and k <= chapters[i][1]:
		break
print(n - i)


n = int(input())
l = []
r = []
for i in range(n):
	(x, y) = [int(s) for s in input().split()]
	l.append(x)
	r.append(y)
m = int(input())
ans = 0
for i in range(len(l)):
	if m <= r[i]:
		ans += 1
print(ans)


n = int(input())
parts = [list(map(int, input().split())) for _ in range(n)]
k = int(input())
for i in range(n):
	(l, r) = parts[i]
	if l <= k <= r:
		print(n - i)
		break


x = int(input())
arr = []
for i in range(x):
	arr.append(list(map(int, input().split())))
j = int(input())
sg = []
for i in range(x):
	sg.append(list(range(arr[i][0], arr[i][1] + 1)))
for i in range(x):
	if j in sg[i]:
		c = i
		break
print(x - i)


n = int(input())
l = []
for i in range(n):
	a = input().split()[1]
	l.append(int(a))
c = int(input())
m = n
for i in l:
	if c > i:
		m -= 1
print(m)


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
from types import CodeType, new_class
n = int(input())
a = []
for x in range(n):
	a.append([int(x) for x in input().split()])
s = int(input())
for x in range(n):
	if a[x][0] <= s <= a[x][1]:
		print(n - x)
		exit()


t = int(input())
list1 = []
for i in range(t):
	(x, y) = map(int, input().split())
	list1.append(x)
	list1.append(y)
a = int(input())
for i in list1:
	if a < i:
		c = list1.index(i)
		break
	elif a == i:
		c = list1.index(i)
		break
d = c // 2
ans = t - d
print(ans)


import itertools
import collections
import bisect
import sys
input = sys.stdin.readline

def main():
	N = int(input())
	l = []
	for _ in range(N):
		(f, e) = map(int, input().split())
		l.append(e)
	m = int(input())
	ans = 0
	for e in l:
		if m <= e:
			ans += 1
	print(ans)
main()


n = int(input())
list1 = []
for _ in range(n):
	list1.append(tuple(map(int, input().split())))
k = int(input())
temp = 0
for i in list1:
	if i[0] <= k and i[1] >= k:
		print(n - temp)
		break
	temp += 1


n = int(input())
a = []
for i in range(n):
	(l, r) = list(map(int, input().split()))
	a.append([l, r])
k = int(input())
for i in range(n):
	if a[i][0] <= k <= a[i][1]:
		c = i
print(n - c)


n = int(input())
l = [0] * n
r = [0] * n
for i in range(n):
	(l[i], r[i]) = map(int, input().split(' '))
k = int(input())
for i in range(n):
	if k <= r[i]:
		print(n - i)
		exit()


def main():
	n = int(input())
	m = dict()
	for i in range(n):
		[start, end] = list(map(int, input().split(' ')))
		for j in range(start, end + 1):
			m[j] = i
	page = int(input())
	k = m[page]
	print(n - k)
main()


n = int(input())
pages = []
for i in range(0, n):
	(a, b) = input().split(' ')
	b = int(b)
	pages.append(b)
k = int(input())
total = len(pages)
i = 0
for var in pages:
	if var >= k:
		result = total - i
		print(str(result) + '\n')
		break
	i = i + 1


n = int(input())
_list = [tuple(map(int, input().split())) for i in range(n)]
k = int(input())
c = 0
for i in range(len(_list)):
	if k <= _list[i][1]:
		c = i
		break
print(n - c)


n = int(input())
b = [list(map(int, input().split())) for i in range(n)]
k = int(input())
for (i, bi) in enumerate(b):
	if k in range(bi[0], bi[1] + 1):
		print(n - i)


a = int(input())
x = []
for i in range(a):
	(l, r) = list(map(int, input().split()))
	x.append(r)
k = int(input())
if k - 1 < x[0]:
	print(a)
elif k - 1 == x[0]:
	print(a - 1)
else:
	for i in range(1, len(x)):
		if k - 1 < x[i]:
			print(a - i)
			break
		elif k - 1 == x[i]:
			print(a - i - 1)
			break


import sys
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_strList_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 = get_int()
chapters = []
for i in range(n):
	chapters.append(get_list())
marker = get_int()
for i in range(n):
	if marker <= chapters[i][1]:
		pt(n - i)
		break


l = int(input())
mas = []
for i in range(l):
	k = input().split(' ')
	mas.append(k)
s = int(input())
j = 0
for i in range(l):
	if int(mas[i][1]) >= s:
		break
	j += 1
print(l - j)


n = int(input())
chapters = list(map(lambda x: int(input().split()[-1]), range(n)))
k = int(input())
ans = len(list(filter(lambda p: p >= k, chapters)))
print(ans)


n = int(input())
l1 = []
for i in range(n):
	l = list(map(int, input().split()))
	x = l[0]
	y = l[1]
	for j in range(x, y + 1):
		l1.append(j)
	l1.append(0)
x = int(input())
c = 0
for i in range(len(l1)):
	if l1[i] == 0:
		c = c + 1
	elif l1[i] == x:
		break
print(n - c)


a = int(input())
c = [0] * a
for i in range(a):
	(b, c[i]) = map(int, input().split())
d = int(input())
i = 0
while c[i] < d:
	i += 1
print(a - i)


n = int(input())
nn = n
chapters = []
while n > 0:
	(l, r) = map(int, input().split())
	chapters.append(l)
	n -= 1
c = int(input())
res = 0
for (idx, page) in enumerate(chapters):
	if page <= c:
		res = idx
print(nn - res)


lst = []
for _ in range(int(input())):
	lst.append([int(i) for i in input().split()])
k = int(input())
nd = 0
for i in lst:
	(a, b) = i
	if k >= a and k <= b:
		break
	else:
		nd += 1
print(len(lst) - nd)


n = int(input())
lk = []
for i in range(n):
	(l, k) = map(int, input().split())
	lk.append([l, k])
k = int(input())
minus = 0
for c in lk:
	if k > c[1]:
		minus += 1
	else:
		break
print(n - minus)


b = []
k = 0
a = int(input())
for i in range(0, 2 * a, 2):
	b.append(i)
	b.append(i + 1)
	(b[i], b[i + 1]) = map(int, input().split())
c = int(input())
for i in range(1, 2 * a, 2):
	if c > b[i]:
		k += 1
print(a - k)


n = int(input())
chapters = []
for i in range(n):
	s = input().split(' ')
	chapters.append((int(s[0]), int(s[1])))
k = int(input())
for (i, chapter) in enumerate(chapters):
	(chapter_b, chapter_e) = chapter
	if chapter_b <= k <= chapter_e:
		print(n - i)
		exit()
print(1)


x = int(input())
lst = []
for i in range(0, x):
	lst.append(tuple(map(int, input().split())))
y = int(input())
count = 0
for i in lst:
	if y in range(i[0], i[1] + 1):
		break
	else:
		count += 1
print(x - count)


n = int(input())
a = [0] * n
for i in range(n):
	(q, w) = map(int, input().split())
	a[i] = [q, w]
k = int(input())
for i in range(n):
	if a[i][1] >= k:
		print(n - i)
		exit(0)
print(0)


def nastya(n, ls, k):
	c = 0
	for i in range(n):
		if k > ls[i][1]:
			c = c + 1
		else:
			return n - c
	return n - c
n = int(input())
ls = [[int(j) for j in input().split()] for i in range(n)]
k = int(input())
print(nastya(n, ls, k))


n = int(input())
L = []
for i in range(n):
	L.append([int(x) for x in input().split()])
x = int(input())
for i in L:
	if i[0] <= x <= i[1]:
		print(len(L) - L.index(i))


from sys import stdin, stdout
from math import *
n = int(input())
p = []
for i in range(n):
	(l, r) = map(int, input().split())
	p.append([l, r])
a = int(input())
ans = n
for i in range(n):
	if p[i][1] < a:
		ans = ans - 1
print(ans)


n = int(input())
a = []
for i2 in range(n):
	(l, r) = [int(i) for i in input().split()]
	a.append((l, r))
k = int(input())
r = n
for i2 in range(n):
	if a[i2][1] < k:
		r += -1
print(r)


import sys

def main():
	inp = sys.stdin.read().strip().split('\n')
	p = int(inp[-1])
	n = int(inp[0])
	for i in range(1, n + 1):
		(x, y) = map(int, inp[i].split())
		if x <= p <= y:
			return n - i + 1
print(main())


tmp = []
n = int(input())
for _ in range(n):
	tmp.append(input().split())
c = 1
x = int(input())
for __ in range(n):
	if x <= int(tmp[__][0]):
		c += n - __
		if x == int(tmp[__][0]):
			c -= 1
		break
print(c)


l = []
for i in range(int(input())):
	l.append(list(map(int, input().split())))
total = len(l)
k = int(input())
for i in range(len(l)):
	if k >= l[i][0] and k <= l[i][1]:
		break
	total -= 1
print(str(total))


import math
from collections import defaultdict as dd
n = int(input())
p = []
for _ in range(n):
	(l, r) = [int(i) for i in input().split()]
	p.append([l, r])
k = int(input())
c = 0
for i in range(n):
	(l, r) = p[i]
	if k <= r:
		c = i
		break
print(n - c)


n = int(input())
List = list()
for i in range(0, n):
	a = input().split()
	r = int(a[1])
	List.append(r)
x = int(input())
ans = int(0)
for i in List:
	if i >= x:
		ans += 1
print(ans)


n = int(input())
l = []
for i in range(0, n):
	(a, b) = map(int, input().split(' '))
	l.append(a)
	l.append(b)
k = int(input())
c = 0.0
for j in range(0, n * 2):
	if k < l[j]:
		c = c + 0.5
print(int(c) + 1)


n = int(input())
p = []
for i in range(n):
	(l, r) = map(int, input().split())
	p1 = [l, r]
	p.append(p1)
k = int(input())
for i in range(n):
	if k <= p[i][1]:
		print(len(p[i:]))
		break


a = int(input())
(l1, r1) = ([], [])
for i in range(a):
	(l, r) = map(int, input().split())
	l1.append(l)
	r1.append(r)
f = int(input())
h = 0
for j in range(a):
	if l1[j] <= f <= r1[j]:
		h = j
		break
print(a - h)


n = int(input())
l = []
s = []
for i in range(n):
	x = list(map(int, input().split()))
	l.append(x)
m = int(input())
for i in range(n):
	for j in range(l[i][0], l[i][1] + 1):
		if m == j:
			print(n - i)


n = int(input())
data = list()
for i in range(n):
	(l, r) = [int(e) for e in input().split()]
	data.append(r)
mark = int(input())
for i in range(n):
	if data[i] >= mark:
		print(n - i)
		break


def ip():
	return input().split()
n = int(input())
l3 = []
l1 = []
l2 = []
for i in range(n):
	(f, l) = ip()
	f = int(f)
	l1.append(f)
	l = int(l)
	l2.append(l)
d = l2[-1] + 1
for i in range(d):
	l3.append(0)
for i in l2:
	l3[i] = 1
k = int(input())
for i in range(k):
	l3[i] = 0
ans = l3.count(1)
print(ans)


chapters = int(input().strip())
book = []
for _ in range(chapters):
	book.append(int(input().strip().split()[1]))
page = int(input().strip())
index = 0
for (i, chapter) in enumerate(book):
	if chapter >= page:
		index = i
		break
print(len(book[i:]))


n = int(input())
p = []
for _ in range(n):
	(a, b) = [int(i) for i in input().split()]
	p.append([a, b])
k = int(input())
z = n
for i in range(n):
	if k >= p[i][0] and k <= p[i][1]:
		z = i
		break
print(n - z)


a = []
n = int(input())
for i in range(n):
	a.append(list(map(int, input().split())))
k = int(input())
for i in range(n):
	if k in a[i] or k < a[i][1]:
		print(n - i)
		exit()


n = int(input())
a = []
for i in range(n):
	l = list(input().split())
	q = [int(i) for i in l]
	a.append(q)
k = int(input())
for j in range(n):
	if a[j][0] <= k <= a[j][1]:
		print(n - j)
		break


n = int(input())
l = []
s = []
for i in range(n):
	l += list(map(int, input().split()))
k = int(input())
for i in range(n * 2):
	if i % 2 != 0:
		s.append(l[i])
for i in range(len(s)):
	if k <= s[i]:
		print(len(s) - i)
		break


t = 1
while t > 0:
	t -= 1
	n = int(input())
	l = [list(map(int, input().split())) for i in range(n)]
	k = int(input())
	for i in range(n):
		if l[i][0] < k and l[i][1] < k:
			continue
		else:
			print(n - i)
			break


from bisect import bisect
n = int(input())
rs = sorted((int(input().split()[0]) for i in range(n)))
k = int(input())
print(n - bisect(rs, k) + 1)


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
l = []
for _ in range(t):
	(le, ri) = M()
	l.append((le, ri))
x = I()
for i in range(t):
	if x <= l[i][1]:
		print(t - i)
		break


nn = int(input())
ll = []
for s in range(1, nn + 1):
	(aa, bb) = map(int, input().split())
	ll.append((aa, bb))
k = int(input())
for i in range(nn + 1):
	if i == nn:
		break
	if ll[i][0] <= k and ll[i][1] >= k:
		break
print(nn - i)


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


idx = []
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	idx.append(r)
p = int(input())
print(sum((r >= p for r in idx)))


n = int(input())
ll = []
rr = []
for i in range(n):
	(l, r) = map(int, input().split())
	ll.append(l)
	rr.append(r)
k = int(input())
for i in range(n):
	if k >= ll[i] and k <= rr[i]:
		print(n - i)


def remaining_chapter(n, l, r, k):
	for i in range(0, n):
		if k <= int(r[i]):
			return n
		else:
			n -= 1
	return 0
n = int(input())
l = [None] * n
r = [None] * n
for i in range(0, n):
	(l[i], r[i]) = input().split(' ')
k = int(input())
print(remaining_chapter(n, l, r, k))


number_of_chapter = int(input())
liste = []
for i in range(number_of_chapter + 1):
	liste.append(input().split(' '))
for i in liste:
	if i == liste[-1]:
		break
	(i[0], i[1]) = (int(i[0]), int(i[1]))
findit = int(liste[-1][0])
del liste[-1]
for i in liste:
	if i[0] <= findit <= i[1]:
		hehe = liste.index(i)
		break
print(len(liste) - hehe)


t = int(input())
c = []
for i in range(t):
	temp = [int(x) for x in input().split()]
	c.append(temp)
k = int(input())
for i in range(t):
	if c[i][0] <= k and k <= c[i][1]:
		print(t - i)
		break


ar = [1]
for _ in range(int(input())):
	(l, r) = input().split()
	l = int(l)
	r = int(r)
	ar.append(r)
l = len(ar)
x = int(input())
if x == 1:
	print(l - 1)
else:
	for i in range(l):
		if ar[i] >= x:
			print(l - i)
			break


l = []
a = int(input())
for i in [0] * a:
	(z, x) = map(int, input().split())
	l.append(z)
c = int(input())
l1 = l[::-1]
for i in l1:
	if c >= i:
		print(a - l.index(i))
		break


n = int(input())
chapter_info = []
for i in range(n):
	(l, k) = map(int, input().split())
	chapter_info.append([l, k])
k = int(input())
chapter_info.sort()
a = 0
for j in range(0, len(chapter_info)):
	if k < chapter_info[0][1]:
		break
	if chapter_info[j][0] <= k and chapter_info[j][1] >= k:
		a = j
		break
print(len(chapter_info) - a)


n = int(input())
chapters = []
for i in range(n):
	(l, r) = map(int, input().split())
	chapters.append((l, r))
k = int(input())
for i in range(n):
	(l, r) = chapters[i]
	if k >= l and k <= r:
		print(n - i)
		break


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


n = int(input())
inp = []
result = 0
for i in range(n):
	line = list(map(int, input().split()))
	inp.append(line)
k = int(input())
inp.sort(key=lambda tup: tup[1])
for i in range(n):
	if k <= inp[i][1]:
		result += 1
print(result)


chapters = int(input())
auxchaps = chapters
slistchaps = []
elistchaps = []
while auxchaps != 0:
	chapdelims = input()
	chapdelims_l = chapdelims.split(' ')
	start = int(chapdelims_l[0])
	end = int(chapdelims_l[1])
	slistchaps.append(start)
	elistchaps.append(end)
	auxchaps = auxchaps - 1
lastnotread = int(input())
i = 0
while i < len(slistchaps):
	if lastnotread >= slistchaps[i] and lastnotread <= elistchaps[i]:
		print(str(chapters - i))
		break
	i = i + 1


n_chapters = int(input())
chapters = {}
for i in range(n_chapters):
	(l, r) = [int(j) for j in input().split()]
	chapters[i + 1] = {'left': l, 'right': r}
page = int(input())
for keys in sorted(chapters):
	if page >= chapters[keys]['left'] and page <= chapters[keys]['right']:
		chapters_left = n_chapters - keys + 1
		break
print(chapters_left)


n = int(input())
l_arr = []
r_arr = []
for i in range(n):
	str_inp = input().split()
	(l, r) = (int(str_inp[0]), int(str_inp[1]))
	l_arr.append(l)
	r_arr.append(r)
k = int(input())
for i in range(n):
	if r_arr[i] >= k >= l_arr[i]:
		print(n - i)
		break


import sys
t = int(sys.stdin.readline())
l = []
for i in range(t):
	(m, n) = map(int, sys.stdin.readline().split())
	l.append([m, n])
k = int(sys.stdin.readline())
flag = 0
for i in range(n):
	if k >= l[i][0] and k <= l[i][1]:
		flag = i
		break
ans = t - flag
print(ans)


n = int(input())
(ls, i) = ([list(map(int, input().split())) for i in range(n)], int(input()))
x = 0
for j in range(n):
	if ls[j][1] < i:
		continue
	x += 1
print(x)


num_chapters = int(input())
chapters = []
for line in range(num_chapters):
	chapter = [int(num) for num in input().split(' ')]
	chapters.append(tuple(chapter))
marked_page = int(input())
for (idx, chapter) in enumerate(chapters):
	if marked_page >= chapter[0] and marked_page <= chapter[1]:
		stopped_chapter = idx
		break
chapters_not_read = num_chapters - stopped_chapter
print(chapters_not_read)


def A():
	n = int(input())
	c = []
	for _ in range(n):
		(l, r) = map(int, input().split())
		c.append((l, r))
	k = int(input())
	for i in range(n):
		(l, r) = c[i]
		if l <= k <= r:
			print(n - i)
			break
A()


n = int(input())
li = []
for i in range(n):
	pi = input().split()
	l = int(pi[0])
	r = int(pi[1])
	li.append((l, r))
ix = int(input())
for i in range(len(li)):
	if ix <= li[i][1]:
		break
	n = n - 1
print(n)


n = int(input())
y_cord = []
for i in range(n):
	e = list(map(int, input().split()))
	y_cord.append(e[1])
k = int(input())
count = 0
for j in y_cord:
	if k <= j:
		break
	else:
		count += 1
print(n - count)


n = int(input())
chapters = []
for k in range(n):
	chapters.append(list(map(int, input().split(' '))))
k = int(input())

def find():
	for (i, chapter) in enumerate(chapters):
		if chapter[0] <= k <= chapter[1]:
			return n - i
	return 0
print(find())


num_chapters = int(input())
end_pages = []
for i in range(num_chapters):
	pages = input()
	end = int(pages[pages.find(' ') + 1:])
	end_pages += [end]
index_page = int(input())
for j in range(len(end_pages)):
	if index_page <= end_pages[j]:
		read_chapter = j
		break
print(num_chapters - read_chapter)


ch = int(input())
chap = []
for i in range(ch):
	(a, b) = (int(x) for x in input().split())
	chap.append((a, b))
k = int(input())
for i in range(len(chap)):
	if k > chap[i][1]:
		continue
	else:
		print(len(chap) - i)
		break


import sys

def main():
	N = int(input())
	l = []
	for _ in range(N):
		(f, e) = map(int, input().split())
		l.append(e)
	m = int(input())
	ans = 0
	for e in l:
		if m <= e:
			ans += 1
	print(ans)
main()


n = int(input())
List = []
cn = n
while n != 0:
	List1 = []
	List1 = list(map(int, input().split()))
	List.append(List1)
	n -= 1
k = int(input())
count = 0
for i in range(0, cn):
	if k > List[i][1]:
		count += 1
	else:
		break
print(cn - count)


n = int(input())
l = []
q = []
for i in range(0, n):
	p = input().rstrip().split(' ')
	l.append(int(p[0]))
	q.append(int(p[1]))
k = int(input())
if k in l:
	r = l.index(k)
	print(len(l) - r)
elif k in q:
	r = q.index(k)
	print(len(q) - r)
else:
	for i in range(0, len(l)):
		if k > l[i] and k < q[i]:
			g = i
			break
	print(len(l) - g)


t = int(input())
q = list()
c = 0
e = 0
for i in range(t):
	(l, r) = map(int, input().split())
	q.append(l)
	c += 1
k = int(input())
for i in range(c):
	if k < q[i]:
		ans = c - i + 1
		e = 1
		break
if e == 0:
	ans = c - i
print(ans)


import math
import bisect

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 0:
		return int(input())
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	else:
		return sorted(list(map(int, input().split())))
n = f()
cl = []
for i in range(n):
	(x, y) = f(1)
	cl.append(y)
k = f()
print(n - bisect.bisect_left(cl, k))


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict, deque, Counter, OrderedDict
import threading

def main():
	n = int(input())
	D = [[*map(int, input().split())] for _ in range(n)]
	k = int(input())
	for i in range(n):
		if D[i][0] <= k <= D[i][1]:
			z = i
	print(n - z)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

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

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
s = []
for i in range(t):
	k = list(map(int, input().split()))
	s.append(k)
current = int(input())
chap = 0
prev = 0
for i in range(t):
	page = s[i][1] - s[i][0] + 1
	prev = prev + page
	if prev < current:
		chap = chap + 1
	elif prev > current:
		chap = chap
		break
print(t - chap)


n = int(input())
d = {}
for i in range(1, n + 1):
	(a, b) = map(int, input().split())
	d[i] = (a, b)
r = int(input())
for i in range(1, n + 1):
	if d[i][0] <= r <= d[i][1]:
		print(n - i + 1)
		exit(0)


def main():
	n = int(input())
	l_list = [0] * n
	r_list = [0] * n
	for i in range(n):
		(_l, _r) = [int(x) for x in input().split()]
		l_list[i] = _l
		r_list[i] = _r
	k = int(input())
	for i in range(n):
		_l = l_list[i]
		_r = r_list[i]
		if k <= _r:
			return n - i
res = main()
print(res)


n = int(input())
L = [tuple(map(int, input().split())) for k in range(n)]
j = int(input())
i = 0
for k in L:
	if j in range(k[0], k[1] + 1):
		break
	i += 1
print(n - i)


n = int(input())
ar = []
for i in range(n):
	(a, b) = map(int, input().split())
	ar.append((a, b))
a = int(input())
nn = n
for i in range(nn):
	if ar[i][1] >= a:
		print(n)
		quit()
	n -= 1


n = int(input())
r = []
for i in range(n):
	a = input().split()
	r.append(int(a[1]))
k = int(input())
chap = 0
for i in range(n):
	if r[i] >= k:
		chap += 1
print(chap)


n = int(input())
result = []
for i in range(n):
	(l, r) = [int(x) for x in input().split()]
	result.append([l, r])
k = int(input())
for m in range(n):
	if k >= result[m][0] and k <= result[m][1]:
		break
print(n - m)


l = []
for i in range(int(input())):
	(a, b) = map(int, input().split())
	l.append(b)
n = int(input())
cnt = 0
for j in l:
	if j < n:
		cnt = cnt + 1
print(len(l) - cnt)


a = int(input())
A = []
for i in range(a):
	(x, y) = map(int, input().split())
	A.append(y)
b = int(input())
for i in range(a):
	if b <= A[i]:
		print(a - i)
		break


n = int(input())
X = []
for i in range(n):
	(l, r) = map(int, input().split())
	X.append((l, r))
k = int(input())
for (i, (l, r)) in enumerate(X):
	if l <= k <= r:
		print(n - i)
		exit()


n = int(input())
lr = []
for i in range(n):
	lr.append(list(map(int, input().split())))
k = int(input())
ans = 0
for i in range(n):
	if k >= lr[i][0] and k <= lr[i][1]:
		ans = n - i
		break
print(ans)


n = int(input())
(s, e) = ([], [])
for i in range(n):
	(ss, ee) = list(map(int, input().split(' ')))
	s.append(ss)
	e.append(ee)
k = int(input())
c = 0
for i in range(n):
	if k >= s[i] and k <= e[i]:
		c = i
		break
ans = n - c
print(ans)


chapters = int(input())
pages = []
for i in range(chapters):
	(s, e) = map(lambda x: int(x), input().split(' '))
	pages.append(s)
	pages.append(e)
page = int(input())
for p in pages:
	if p >= page:
		ind = pages.index(p)
		chapters_read = int(ind / 2)
		print(chapters - chapters_read)
		break


l = []
for i in range(int(input())):
	(a, b) = map(int, input().split())
	l.append(b)
c = int(input())
for i in range(len(l)):
	if c <= l[i]:
		print(len(l) - i)
		break


TN = 1

def solution():
	n = int(input())
	lrs = []
	for i in range(n):
		lrs.append(list(map(int, input().split())))
	k = int(input())
	for i in range(n):
		if lrs[i][0] <= k <= lrs[i][1]:
			print(n - i)
			break
while TN != 0:
	solution()
	TN -= 1


n = int(input())
chaps = []
while n > 0:
	(l, h) = map(int, input().split())
	chaps.append(h)
	n = n - 1
miss = len(chaps)
k = int(input())
for a in chaps:
	if k > a:
		miss = miss - 1
	else:
		break
print(miss)


n = int(input())
lst = list((int(input().split()[1]) for _ in range(n)))
k = int(input())
count = 0
for i in lst:
	if k <= i:
		count += 1
print(count)


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
page = int(input())
out = 0
for ch in l:
	if ch[-1] >= page:
		out += 1
print(out)


n = int(input())
lfi = []
for i in range(n):
	l = input().split()
	lfi.append([int(i) for i in l])
k = int(input())
for i in range(n):
	if k >= lfi[i][0] and k <= lfi[i][1]:
		ans = i
		break
print(n - ans)


n = int(input())
re = []
for i in range(n):
	(l, r) = map(int, input().strip().split())
	re.append([l, r])
k = int(input()) - 1
c = 0
for x in re:
	if k >= x[1]:
		c += 1
	else:
		break
print(n - c)


n = int(input())
l = []
r = []
for chapter in range(n):
	(a, b) = input().split()
	l.append(int(a))
	r.append(int(b))
zipped_l_r = list(zip(l, r))
k = int(input())
for zip_item in zipped_l_r:
	if zip_item[0] <= k <= zip_item[1]:
		unread_chapters = zipped_l_r.index(zip_item)
		res = len(zipped_l_r) - unread_chapters
		print(res)


def book(lst, k):
	(result, i) = (len(lst), 0)
	while i < len(lst):
		if k <= lst[i][1]:
			result = len(lst) - i
			break
		else:
			result -= 1
		i += 1
	return result
n = int(input())
a = list()
for x in range(n):
	(l, r) = [int(j) for j in input().split()]
	a.append([l, r])
K = int(input())
print(book(a, K))


book = []
for m in range(int(input())):
	book.append(list(map(int, input().split())))
k = int(input())
chapters = 0
for i in range(len(book)):
	if k <= book[i][1]:
		break
print(len(book) - i)


a = int(input())
A = []
for i in range(a):
	(q, w) = map(int, input().split())
	A.append(q)
A.append(w + 1)
b = int(input())
k = False
i = 0
while k == False:
	if A[i] <= b and b < A[i + 1]:
		k = True
	else:
		i += 1
print(a - i)


n = int(input())
b = []
for i in range(n):
	a = input().split()
	b += [int(a[1])]
x = int(input())
for i in range(n):
	if x <= b[i]:
		print(n - i)
		break


n = int(input())
ending_pages = []
for i in range(n):
	(l, r) = map(int, input().split())
	ending_pages.append(r)
k = int(input())
for i in range(n):
	if k <= ending_pages[i]:
		print(n - i)
		break
	else:
		pass


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


import bisect
a = []
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split(' '))
	a.append(x)
	a.append(y)
k = int(input())
t = bisect.bisect_left(a, k)
print(n - t // 2)


n = int(input())
page_n = []
for i in range(n):
	page_n.append(input().split())
k = int(input())
for l in range(n):
	if k in range(int(page_n[l][0]), int(page_n[l][1]) + 1):
		print(n - l)


n = int(input())
l1 = []
l2 = []
ans = 0
for i in range(n):
	(a, b) = map(int, input().split())
	l1.append(a)
	l2.append(b)
k = int(input())
for i in range(n):
	if k < l1[i] or (k >= l1[i] and k <= l2[i]):
		ans += 1
print(ans)


n = int(input())
l = []
for i in range(n):
	l1 = list(map(int, input().split()))
	l.append(l1)
k = int(input())
c = 0
for i in range(n):
	if l[i][1] >= k:
		print(n - i)
		c = 1
		break


n = int(input())
book = []
count = n
for i in range(n):
	my_list = list(map(int, input().split()))
	book.append(my_list)
k = int(input())
for j in range(n):
	if k <= book[j][1]:
		break
	count -= 1
print(count)


def chisla():
	p = input().split(' ')
	return (int(p[0]), int(p[1]))
n = int(input())
s = []
for i in range(n):
	(r, t) = chisla()
	s.append([r, t])
k = int(input())
for i in range(n):
	(r, t) = s[i]
	if r <= k <= t:
		print(n - i)


n = int(input())
lastpages = []
for i in range(0, n):
	(l, r) = input().split(' ')
	lastpages.append(int(r))
k = int(input())
counter = 0
for i in lastpages:
	if k > i:
		counter = counter + 1
	else:
		break
print(n - counter)


n = int(input())
l = []
for o in range(n):
	p = [int(x) for x in input().split()]
	l.append(p)
k = int(input())
for i in range(len(l)):
	if k >= l[i][0] and k <= l[i][1]:
		break
print(n - i)


chapters = int(input())
eoc = []
for k in range(chapters):
	(p_start, p_end) = [int(n) for n in input().split(' ')]
	eoc.append(p_end)
pages = int(input()) - 1
i = 0
while pages - eoc[i] >= 0:
	i += 1
print(chapters - i)


n = int(input())
chapters = []
for i in range(n):
	(start, end) = input().split()
	chapters.append((int(start), int(end)))
k = int(input())
for i in range(len(chapters)):
	if chapters[i][0] <= k <= chapters[i][1]:
		print(n - i)
		break


n_chapters = int(input())
pages = []
for i in range(n_chapters):
	pages.append(input().split(' '))
first_not_read = int(input())
contador = 0
for i in pages:
	if first_not_read <= int(i[1]):
		contador += 1
print(contador)


n = int(input())
b = n
d = []
while n > 0:
	c = input().split(' ')
	d.append([int(c[0]), int(c[1])])
	n -= 1
k = int(input())
for m in d:
	if k <= int(m[1]) and k >= int(m[0]):
		print(b - d.index(m))


n = int(input(''))
b = []
for iii in range(n):
	(l, r) = map(int, input().split())
	b.append(r)
k = int(input(''))
c = 0
for i in range(n):
	if k > b[i]:
		c += 1
	else:
		break
print(n - c)


x = int(input())
pages = []
for i in range(x):
	chapter = list(map(int, input().split()))
	pages.append(chapter)
k = int(input())
for t in range(len(pages)):
	if k <= pages[t][1]:
		stop = t
		break
print(len(pages) - stop)


class Chapter:

	def __init__(self, l, r):
		self.l = l
		self.r = r
n = int(input())
seq = []
for _ in range(n):
	(l, r) = map(int, input().split())
	seq += [Chapter(l, r)]
k = int(input())
for (i, v) in enumerate(seq):
	if k <= v.r:
		print(n - i)
		break


def main():
	n = int(input())
	(L, R) = ([], [])
	for i in range(n):
		(l, r) = map(int, input().split())
		L += [l]
		R += [r]
	k = int(input())
	for i in range(n):
		if k >= L[i] and k <= R[i]:
			print(n - i)
			break
main()


n = int(input())
arr = []
for i in range(n):
	(p, q) = map(int, input().split())
	arr.append([p, q])
k = int(input())
for i in range(n):
	if k >= arr[i][0] and k <= arr[i][1]:
		print(n - i)
		break


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import *
import functools
import sys
import math
import random
MAX = sys.maxsize
MAXN = 10 ** 6 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN(x=' '):
	return map(int, sys.stdin.readline().strip().split(x))

def charIN():
	return sys.stdin.readline().strip().split()

def trace(x, y):
	print(x, '=', y)
n = int(input())
le = [0]
for i in range(1, n + 1):
	(l, r) = numIN()
	x = [i] * (r - l + 1)
	le += x
k = int(input())
print(len(set(le[k:])))