A team of three programmers is going to play a contest. The contest consists of $n$ problems, numbered from $1$ to $n$. Each problem is printed on a separate sheet of paper. The participants have decided to divide the problem statements into three parts: the first programmer took some prefix of the statements (some number of first paper sheets), the third contestant took some suffix of the statements (some number of last paper sheets), and the second contestant took all remaining problems. But something went wrong — the statements were printed in the wrong order, so the contestants have received the problems in some random order.

The first contestant has received problems $a_{1, 1}, a_{1, 2}, \dots, a_{1, k_1}$. The second one has received problems $a_{2, 1}, a_{2, 2}, \dots, a_{2, k_2}$. The third one has received all remaining problems ($a_{3, 1}, a_{3, 2}, \dots, a_{3, k_3}$).

The contestants don't want to play the contest before they redistribute the statements. They want to redistribute them so that the first contestant receives some prefix of the problemset, the third contestant receives some suffix of the problemset, and the second contestant receives all the remaining problems.

During one move, some contestant may give one of their problems to other contestant. What is the minimum number of moves required to redistribute the problems?

It is possible that after redistribution some participant (or even two of them) will not have any problems.


-----Input-----

The first line contains three integers $k_1, k_2$ and $k_3$ ($1 \le k_1, k_2, k_3 \le 2 \cdot 10^5, k_1 + k_2 + k_3 \le 2 \cdot 10^5$) — the number of problems initially taken by the first, the second and the third participant, respectively.

The second line contains $k_1$ integers $a_{1, 1}, a_{1, 2}, \dots, a_{1, k_1}$ — the problems initially taken by the first participant.

The third line contains $k_2$ integers $a_{2, 1}, a_{2, 2}, \dots, a_{2, k_2}$ — the problems initially taken by the second participant.

The fourth line contains $k_3$ integers $a_{3, 1}, a_{3, 2}, \dots, a_{3, k_3}$ — the problems initially taken by the third participant.

It is guaranteed that no problem has been taken by two (or three) participants, and each integer $a_{i, j}$ meets the condition $1 \le a_{i, j} \le n$, where $n = k_1 + k_2 + k_3$.


-----Output-----

Print one integer — the minimum number of moves required to redistribute the problems so that the first participant gets the prefix of the problemset, the third participant gets the suffix of the problemset, and the second participant gets all of the remaining problems.


-----Examples-----
Input
2 1 2
3 1
4
2 5

Output
1

Input
3 2 1
3 2 1
5 4
6

Output
0

Input
2 1 3
5 6
4
1 2 3

Output
3

Input
1 5 1
6
5 1 2 4 7
3

Output
2



-----Note-----

In the first example the third contestant should give the problem $2$ to the first contestant, so the first contestant has $3$ first problems, the third contestant has $1$ last problem, and the second contestant has $1$ remaining problem.

In the second example the distribution of problems is already valid: the first contestant has $3$ first problems, the third contestant has $1$ last problem, and the second contestant has $2$ remaining problems.

The best course of action in the third example is to give all problems to the third contestant.

The best course of action in the fourth example is to give all problems to the second contestant.

Source: codeforces | Difficulty: HARD
Tags: Dynamic programming

Data structures

Greedy algorithms


Solutions:
(k1, k2, k3) = list(map(int, input().split(' ')))
n = k1 + k2 + k3
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))
B = list(range(k1 + k2 + k3))
for i in a:
	B[i - 1] = 1
for i in b:
	B[i - 1] = 2
for i in c:
	B[i - 1] = 3
(p1, p2, p3) = (0, 0, 0)
inf = int(2 * 100000.0 + 3)
stateStorage = [[inf for i in range(3)] for j in range(2)]
for i in range(3):
	stateStorage[n % 2][i] = 0

def fillMatrix(n):
	for i in range(n - 1, -1, -1):
		stateStorage[i % 2][0] = 1 - int(B[i] == 1) + min(stateStorage[(i + 1) % 2][0], stateStorage[(i + 1) % 2][1], stateStorage[(i + 1) % 2][2])
		stateStorage[i % 2][1] = 1 - int(B[i] == 2) + min(stateStorage[(i + 1) % 2][2], stateStorage[(i + 1) % 2][1])
		stateStorage[i % 2][2] = 1 - int(B[i] == 3) + stateStorage[(i + 1) % 2][2]
	return min(stateStorage[0][0], stateStorage[0][1], stateStorage[0][2])
ans = fillMatrix(n)
print(ans)


def main():
	(k1, k2, k3) = map(int, input().split())
	n = k1 + k2 + k3
	arr = [0 for _ in range(n)]
	a = list(map(int, input().split()))
	for i in a:
		arr[i - 1] = 1
	a = list(map(int, input().split()))
	for i in a:
		arr[i - 1] = 2
	a = list(map(int, input().split()))
	for i in a:
		arr[i - 1] = 3
	dp = [0, 0, 0]
	for i in arr:
		if i == 1:
			dp[1] += 1
			dp[2] += 1
		if i == 2:
			dp[1] = min(dp[0], dp[1])
			dp[0] += 1
			dp[2] += 1
		if i == 3:
			dp[2] = min(dp[0], dp[1], dp[2])
			dp[0] += 1
			dp[1] += 1
	print(min(dp))

def __starting_point():
	main()
__starting_point()


import sys, math
import io, os

def data():
	return sys.stdin.buffer.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = float('inf')
mod = int(1000000000.0) + 7
(k1, k2, k3) = mdata()
n = k1 + k2 + k3
a = [0] * n
for i in mdata():
	a[i - 1] = 0
for i in mdata():
	a[i - 1] = 1
for i in mdata():
	a[i - 1] = 2
cnt = [[0 for i in range(3)] for i in range(n + 1)]
l = [0] * (n + 1)
m = 0
for i in range(n):
	cnt[i + 1] = cnt[i][:]
	cnt[i + 1][a[i]] += 1
	if cnt[i + 1][1] - cnt[i + 1][0] < m:
		l[i + 1] = i + 1
		m = cnt[i + 1][1] - cnt[i + 1][0]
	else:
		l[i + 1] = l[i]
cnt.append(cnt[-1])
ans = INF
for i in range(n + 1):
	a1 = l[i]
	val = cnt[a1][1] - cnt[a1][0] + cnt[i][2] + cnt[n][0] + cnt[n][1] - cnt[i][1]
	ans = min(ans, val)
out(ans)


def solve(a, b, c):
	n = len(a) + len(b) + len(c)
	arr = [0] * (n + 1)
	for i in a:
		arr[i] = 0
	for i in b:
		arr[i] = 1
	for i in c:
		arr[i] = 2
	dp = [[n + 10] * (n + 1) for _ in range(3)]
	for i in range(3):
		dp[i][0] = 0
		for j in range(1, n + 1):
			dp[i][j] = dp[i][j - 1] + (arr[j] != i)
			if i:
				dp[i][j] = min(dp[i - 1][j], dp[i][j])
	return dp[2][n]

def __starting_point():
	(k1, k2, k3) = map(int, input().split(' '))
	n = k1 + k2 + k3
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	assert n == len(a) + len(b) + len(c)
	arr = [0 for _ in range(n)]
	for i in a:
		arr[i - 1] = 1
	for i in b:
		arr[i - 1] = 2
	for i in c:
		arr[i - 1] = 3
	dp = [0, 0, 0]
	print(solve(a, b, c))
__starting_point()


mod = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 6)
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math
import heapq
import random

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	(k1, k2, k3) = cin()
	a = ain()
	b = ain()
	c = ain()
	d = {}
	for i in a:
		d[i - 1] = 1
	for i in b:
		d[i - 1] = 2
	for i in c:
		d[i - 1] = 3
	n = k1 + k2 + k3
	a = [100000000000] * 4
	b = []
	for i in range(n + 1):
		b.append(a[:])
	b[0][1] = 0
	for i in range(n):
		for j in range(1, 4):
			for k in range(j, 4):
				x = 0
				if d[i] != k:
					x = 1
				b[i + 1][k] = min(b[i + 1][k], b[i][j] + x)
	print(min(b[n]))
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


numbers = list(map(int, input().split()))
k1 = numbers[0]
k2 = numbers[1]
k3 = numbers[2]
n = 3
suma = 0
for (i, elem) in enumerate(numbers):
	suma = suma + elem
lst = []
for i in range(suma):
	lst.append(0)
for i in range(3):
	problems = list(map(int, input().split()))
	for j in problems:
		lst[j - 1] = i
p = []
for i in range(3):
	p.append(-1)
vect = []
for i in range(suma + 1):
	vect.append(1)
for i in range(suma):
	for j in range(lst[i] + 1):
		if p[j] >= 0:
			vect[i] = max(vect[i], 1 + vect[p[j]])
	x = lst[i]
	p[lst[i]] = i
maxi = -1
for i in vect:
	if maxi < i:
		maxi = i
print(suma - maxi)


import sys
(k1, k2, k3) = [int(i) for i in sys.stdin.readline().split()]
k = [[], [], [], []]
for j in range(1, 4):
	k[j] = [int(i) for i in sys.stdin.readline().split()]
n = k1 + k2 + k3
k_4 = []
for f in [2, 3]:
	k_4.extend(((jlk, f) for jlk in k[f]))
k_4.sort(reverse=True)
ndd = [0] * (k2 + k3 + 1)
for j in range(1, k2 + k3 + 1):
	if k_4[j - 1][1] == 3:
		ndd[j] = ndd[j - 1]
	else:
		ndd[j] = ndd[j - 1] + 1
fj = []
for j in range(k2 + k3 + 1):
	fj.append(k3 - j + 2 * ndd[j])
mnfj_i = []
mn = fj[0]
for i in range(k2 + k3 + 1):
	mn = min(mn, fj[i])
	mnfj_i.append(mn)
k3s = set(k[3])
cnt_lea3 = [0] * (n + 1)
for i in range(1, n + 1):
	if i in k3s:
		cnt_lea3[i] = cnt_lea3[i - 1] + 1
	else:
		cnt_lea3[i] = cnt_lea3[i - 1]
k2s = set(k[2])
cnt_lea2 = [0] * (n + 1)
for i in range(1, n + 1):
	if i in k2s:
		cnt_lea2[i] = cnt_lea2[i - 1] + 1
	else:
		cnt_lea2[i] = cnt_lea2[i - 1]
k1s = set(k[1])
cnt_lea1 = [0] * (n + 1)
for i in range(1, n + 1):
	if i in k1s:
		cnt_lea1[i] = cnt_lea1[i - 1] + 1
	else:
		cnt_lea1[i] = cnt_lea1[i - 1]
ans = 5 * (k1 + k2 + k3)
for alpha in range(n + 1):
	ub = k2 + k3 - cnt_lea3[alpha] - cnt_lea2[alpha]
	ans = min(ans, mnfj_i[ub] - cnt_lea3[alpha] + k1 + alpha - 2 * cnt_lea1[alpha])
print(ans)


n = sum(list(map(int, input().split())))
A = [0 for i in range(n)]
DP = [[0 for i in range(3)] for i in range(n)]
for i in range(3):
	for j in map(int, input().split()):
		A[j - 1] = i
DP[0] = [A[0] != i for i in range(3)]
for i in range(1, n):
	DP[i][0] = DP[i - 1][0] + (A[i] != 0)
	DP[i][1] = min(DP[i - 1][0], DP[i - 1][1]) + (A[i] != 1)
	DP[i][2] = min(DP[i - 1]) + (A[i] != 2)
print(min(DP[n - 1]))


(k1, k2, k3) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a)
b = sorted(b)
c = sorted(c)
n = k1 + k2 + k3
l = [0] * (n + 1)
r = [0] * (n + 1)
p = 0
for i in range(n + 1):
	if p < len(a) and i == a[p]:
		p += 1
	l[i] += len(a) - p
p = 0
for i in range(n + 1):
	if p < len(b) and i == b[p]:
		p += 1
	l[i] += p
p = 0
for i in range(n + 1):
	if p < len(b) and i == b[p]:
		p += 1
	r[i] += len(b) - p
p = 0
for i in range(n + 1):
	if p < len(c) and i == c[p]:
		p += 1
	r[i] += p
r_cum_min = [None] * (n + 1)
r_cum_min[-1] = r[n]
i = n - 1
while i >= 0:
	r_cum_min[i] = min(r[i], r_cum_min[i + 1])
	i -= 1
answer = 1000000000.0
for i in range(n + 1):
	if l[i] + r_cum_min[i] < answer:
		answer = l[i] + r_cum_min[i]
print(answer)


import os
import sys

def main():
	K = read_ints()
	A = [read_ints(), read_ints(), read_ints()]
	print(solve(K, A))

def solve(K, A):
	N = sum(K)
	INF = N + 1
	loc = [-1] * N
	for i in range(3):
		for a in A[i]:
			loc[a - 1] = i
	D = [0, 0, 0]
	for i in loc:
		if i == 0:
			D = [D[0], min(D[0] + 1, D[1] + 1), min(D[0] + 1, D[1] + 1, D[2] + 1)]
		elif i == 1:
			D = [D[0] + 1, min(D[0], D[1]), min(D[0] + 1, D[1] + 1, D[2] + 1)]
		else:
			D = [D[0] + 1, min(D[0] + 1, D[1] + 1), min(D[0], D[1], D[2])]
	return min(D)
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def read_int():
	return int(inp())

def read_ints():
	return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)
main()


(k1, k2, k3) = map(int, input().split())
s = [set([int(o) for o in input().split()]) for i in range(3)]
n = k1 + k2 + k3
dp = [[float('inf')] * 3 for i in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
	for j in range(3):
		for k in range(j, 3):
			dp[i][k] = min(dp[i][k], dp[i - 1][j] + (i not in s[k]))
print(min(dp[n]))


def LIS(X):
	N = len(X)
	P = [0] * N
	M = [0] * (N + 1)
	L = 0
	for i in range(N):
		lo = 1
		hi = L
		while lo <= hi:
			mid = (lo + hi) // 2
			if X[M[mid]] < X[i]:
				lo = mid + 1
			else:
				hi = mid - 1
		newL = lo
		P[i] = M[newL - 1]
		M[newL] = i
		if newL > L:
			L = newL
	S = []
	k = M[L]
	for i in range(L - 1, -1, -1):
		S.append(X[k])
		k = P[k]
	return len(S)
(k1, k2, k3) = list(map(int, input().split()))
a = []
for _ in range(3):
	a.extend(sorted(list(map(int, input().split()))))
print(k1 + k2 + k3 - LIS(a))


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
threading.stack_size(10 ** 8)
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
sys.setrecursionlimit(300000)
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')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 51, func=lambda a, b: a & b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
(a, b, c) = map(int, input().split())
s = set(map(int, input().split()))
s1 = set(map(int, input().split()))
s2 = set(map(int, input().split()))
dp = [[0 for i in range(3)] for j in range(a + b + c + 1)]
for i in range(1, a + b + c + 1):
	dp[i][0] = dp[i - 1][0]
	dp[i][1] = min(dp[i - 1][1], dp[i - 1][0])
	dp[i][2] = min(dp[i - 1][1], dp[i - 1][0], dp[i - 1][2])
	if i in s:
		dp[i][1] += 1
		dp[i][2] += 1
	elif i in s1:
		dp[i][0] += 1
		dp[i][2] += 1
	else:
		dp[i][1] += 1
		dp[i][0] += 1
print(min(dp[-1]))


def input_sorted_int_list():
	return sorted(map(int, input().split()))

def update_moves_count_list(moves_count_list, tasks_list, from_left_to_right):
	p = 0
	for i in range(n + 1):
		if p < len(tasks_list) and i == tasks_list[p]:
			p += 1
		if from_left_to_right:
			moves_count_list[i] += len(tasks_list) - p
		else:
			moves_count_list[i] += p
(k1, k2, k3) = map(int, input().split())
n = k1 + k2 + k3
a = input_sorted_int_list()
b = input_sorted_int_list()
c = input_sorted_int_list()
left_moves_count = [0] * (n + 1)
right_moves_count = [0] * (n + 1)
update_moves_count_list(left_moves_count, a, True)
update_moves_count_list(left_moves_count, b, False)
update_moves_count_list(right_moves_count, b, True)
update_moves_count_list(right_moves_count, c, False)
r_cum_min = [None] * (n + 1)
r_cum_min[-1] = right_moves_count[n]
i = n - 1
while i >= 0:
	r_cum_min[i] = min(right_moves_count[i], r_cum_min[i + 1])
	i -= 1
answer = 1000000000.0
for i in range(n + 1):
	if left_moves_count[i] + r_cum_min[i] < answer:
		answer = left_moves_count[i] + r_cum_min[i]
print(answer)


(k1, k2, k3) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))
n = k1 + k2 + k3
assign = [0] * n
for i in l1:
	assign[i - 1] = 1
for i in l2:
	assign[i - 1] = 2
for i in l3:
	assign[i - 1] = 3
ilenie3wprawo = [0] * n
ilenie1wlewo = [0] * n
ilenie1wlewo[n - 1] = k2 + k3
i = n - 1
ilenie3wprawo[n - 1] = 1 if assign[n - 1] != 3 else 0
while i > 0:
	i -= 1
	ilenie3wprawo[i] = ilenie3wprawo[i + 1]
	ilenie1wlewo[i] = ilenie1wlewo[i + 1]
	if assign[i] != 3:
		ilenie3wprawo[i] += 1
	if assign[i + 1] != 1:
		ilenie1wlewo[i] -= 1
odp = [0] * (n + 1)
odp[n] = k2 + k3
i = n
while i > 1:
	i -= 1
	if assign[i] == 2:
		odp[i] = odp[i + 1] - 1
	if assign[i] == 1:
		odp[i] = odp[i + 1] + 1
	if assign[i] == 3:
		odp[i] = min(odp[i + 1], ilenie1wlewo[i - 1] + ilenie3wprawo[i])
if assign[0] == 2:
	odp[0] = odp[1] - 1
if assign[0] == 1:
	odp[0] = odp[1] + 1
if assign[0] == 3:
	odp[0] = min(odp[i + 1], ilenie3wprawo[0])
print(min(odp))


k = [int(i) for i in input().split(' ')]
n = sum(k)
a = [0] * n
for I in range(3):
	line = [int(i) for i in input().split(' ')]
	for item in line:
		a[item - 1] = I
dp = [1] * n
cur = [-1, -1, -1]
for i in range(n):
	for j in range(a[i] + 1):
		if cur[j] >= 0:
			dp[i] = max(dp[i], 1 + dp[cur[j]])
	cur[a[i]] = i
print(n - max(dp))


import sys
input = sys.stdin.readline
(k1, k2, k3) = map(int, input().split())
n = k1 + k2 + k3
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
b = [0] * n
for i in range(k2):
	b[a2[i] - 1] = 1
for i in range(k3):
	b[a3[i] - 1] = 2
cntr = [0] * 3
cntl = [0] * 3
for i in range(n):
	cntr[b[i]] += 1
ans = k1 + k2
best_p = 0
for i in range(n):
	cntl[b[i]] += 1
	cntr[b[i]] -= 1
	best_p = max(best_p, cntl[0] - cntl[1])
	ans = min(ans, cntl[0] + cntl[2] + cntr[0] + cntr[1] - best_p)
print(ans)


(k1, k2, k3) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

def ceil(a, L, R, pivot):
	while L + 1 < R:
		m = (L + R) // 2
		if a[m] > pivot:
			R = m
		else:
			L = m
	return R

def LIS(a, n):
	tails = [0 for _ in range(n + 1)]
	empty = 0
	tails[0] = a[0]
	empty = 1
	for i in range(1, n):
		if a[i] < tails[0]:
			tails[0] = a[i]
		elif a[i] >= tails[empty - 1]:
			tails[empty] = a[i]
			empty += 1
		else:
			tails[ceil(tails, -1, empty - 1, a[i])] = a[i]
	return empty
n = k1 + k2 + k3
abc = [None] * n
for el in a:
	abc[el - 1] = 1
for el in b:
	abc[el - 1] = 2
for el in c:
	abc[el - 1] = 3
print(n - LIS(abc, n))


import math
from decimal import Decimal
import heapq
from collections import deque

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = list(map(int, input().split()))
	return (n, m)

def dva():
	(n, m) = list(map(int, input().split()))
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def fact(a, b):
	c = []
	ans = 0
	f = int(math.sqrt(a))
	for i in range(1, f + 1):
		if a % i == 0:
			c.append(i)
	l = len(c)
	for i in range(l):
		c.append(a // c[i])
	for i in range(len(c)):
		if c[i] <= b:
			ans += 1
	if a / f == f and b >= f:
		return ans - 1
	return ans
(k1, k2, k3) = list(map(int, input().split()))
n = k1 + k2 + k3
a = [-1] * n
x1 = list(map(int, input().split()))
x2 = list(map(int, input().split()))
x3 = list(map(int, input().split()))
for i in x1:
	a[i - 1] = 0
for i in x2:
	a[i - 1] = 1
for i in x3:
	a[i - 1] = 2
ans = k1 + k2
mx = 0
cntl = [0] * 3
cntr = [0] * 3
for i in range(n):
	cntr[a[i]] += 1
for i in range(n):
	cntl[a[i]] += 1
	cntr[a[i]] -= 1
	mx = max(mx, cntl[0] - cntl[1])
	tc = cntr[0] + cntr[1] + cntl[2] + cntl[0] - mx
	ans = min(ans, tc)
print(ans)


def main():
	(n1, n2, n3) = readIntArr()
	n = n1 + n2 + n3
	a = readIntArr()
	b = readIntArr()
	c = readIntArr()
	origPos = [-1 for _ in range(n + 1)]
	for x in a:
		origPos[x] = 1
	for x in b:
		origPos[x] = 2
	for x in c:
		origPos[x] = 3
	dp = makeArr(inf, [n + 1, 4])
	dp[0][1] = 0
	dp[0][2] = 0
	dp[0][3] = 0
	for i in range(1, n + 1):
		for j in range(1, 4):
			dp[i][j] = min(dp[i][j], dp[i][j - 1])
			if origPos[i] != j:
				extraMove = 1
			else:
				extraMove = 0
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + extraMove)
	ans = dp[n][3]
	print(ans)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultVal, dimensionArr):
	dv = defaultVal
	da = dimensionArr
	if len(da) == 1:
		return [dv for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(x, y):
	print('? {} {}'.format(x, y))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ans):
	print('! {}'.format(ans))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
for _abc in range(1):
	main()


import sys
input = sys.stdin.readline
(K1, K2, K3) = map(int, input().split())
N = K1 + K2 + K3
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = [0] * N
for (i, A_) in enumerate([A1, A2, A3], 1):
	for a in A_:
		A[a - 1] = i
a_12to3 = K1 + K2
ans = a_12to3
a_2to1 = 0
cnt_1 = 0
cnt_2 = 0
idx_12 = 0
for a in A:
	if a == 3:
		a_12to3 += 1
	else:
		a_12to3 -= 1
		if a == 1:
			cnt_1 += 1
			if cnt_1 >= cnt_2:
				a_2to1 += cnt_2
				cnt_1 = cnt_2 = 0
		else:
			cnt_2 += 1
	an = a_12to3 + a_2to1 + cnt_1
	ans = min(ans, an)
print(ans)


import sys
input = sys.stdin.readline
(k1, k2, k3) = map(int, input().split())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = sorted(A1) + sorted(A2) + sorted(A3)
import bisect
N = k1 + k2 + k3
DP = [float('inf')] * N
for a in A:
	pos = bisect.bisect_left(DP, a)
	DP[pos] = a
ANS = 0
for i in range(N):
	if DP[i] != float('inf'):
		ANS = i
print(N - (ANS + 1))


(k1, k2, k3) = map(int, input().split())
x1 = list(map(int, input().split()))
x2 = list(map(int, input().split()))
x3 = list(map(int, input().split()))
y = [0] * (k1 + k2 + k3 + 1)
dp = [[0] * 3 for i in range(k1 + k2 + k3 + 1)]
for i in range(k1):
	y[x1[i]] = 1
for i in range(k2):
	y[x2[i]] = 2
for i in range(k3):
	y[x3[i]] = 3
for i in range(1, k1 + k2 + k3 + 1):
	dp[i][0] = dp[i - 1][0] + (y[i] != 1)
	dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + (y[i] != 2)
	dp[i][2] = min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]) + (y[i] != 3)
print(min(dp[k1 + k2 + k3]))


from sys import stdin
input = stdin.readline
r = list(map(int, input().split()))
n = sum(r)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
mp = [0] * -~n
for i in a:
	mp[i] = 0
for i in b:
	mp[i] = 1
for i in c:
	mp[i] = 2
inf = float('inf')
dp = [[inf] * -~n for _ in range(3)]
for i in range(3):
	dp[i][0] = 0
	for j in range(1, n + 1):
		dp[i][j] = dp[i][j - 1] + (mp[j] != i)
		if i:
			dp[i][j] = min(dp[i - 1][j], dp[i][j])
print(dp[2][n])


from sys import stdin
input = stdin.readline
r = list(map(int, input().split()))
n = sum(r)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
mp = [0] * -~n
for i in a:
	mp[i] = 0
for i in b:
	mp[i] = 1
for i in c:
	mp[i] = 2
ans = sum(r[:2])
now = ans
sm0 = 0
sm2 = r[2]
for i in range(1, n + 1):
	sm0 += mp[i] == 0
	sm2 -= mp[i] == 2
	if mp[i] == 2:
		now += 1
	elif mp[i] == 1:
		now -= 1
	else:
		now = min(now, n - sm0 - sm2)
	ans = min(ans, now)
print(ans)


import sys
import bisect
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
INF = 10 ** 9
(anum, bnum, cnum) = [int(item) for item in input().split()]
k = anum + bnum + cnum
a = [int(item) for item in input().split()]
b = [int(item) for item in input().split()]
c = [int(item) for item in input().split()]
holder = [0] * k
for item in a:
	holder[item - 1] = 0
for item in b:
	holder[item - 1] = 1
for item in c:
	holder[item - 1] = 2
dp = [[INF] * (k + 1) for _ in range(3)]
dp[0][0] = 0
dp[1][0] = 0
dp[2][0] = 0
for i in range(k):
	if holder[i] == 0:
		dp[0][i + 1] = min(dp[0][i + 1], dp[0][i])
		dp[1][i + 1] = min(dp[1][i + 1], dp[1][i] + 1)
		dp[2][i + 1] = min(dp[2][i + 1], dp[2][i] + 1)
		dp[1][i + 1] = min(dp[1][i + 1], dp[0][i] + 1)
		dp[2][i + 1] = min(dp[2][i + 1], dp[1][i] + 1)
		dp[2][i + 1] = min(dp[2][i + 1], dp[0][i] + 1)
	elif holder[i] == 1:
		dp[0][i + 1] = min(dp[0][i + 1], dp[0][i] + 1)
		dp[1][i + 1] = min(dp[1][i + 1], dp[1][i])
		dp[2][i + 1] = min(dp[2][i + 1], dp[2][i] + 1)
		dp[1][i + 1] = min(dp[1][i + 1], dp[0][i])
		dp[2][i + 1] = min(dp[2][i + 1], dp[1][i] + 1)
		dp[2][i + 1] = min(dp[2][i + 1], dp[0][i] + 1)
	elif holder[i] == 2:
		dp[0][i + 1] = min(dp[0][i + 1], dp[0][i] + 1)
		dp[1][i + 1] = min(dp[1][i + 1], dp[1][i] + 1)
		dp[2][i + 1] = min(dp[2][i + 1], dp[2][i])
		dp[1][i + 1] = min(dp[1][i + 1], dp[0][i] + 1)
		dp[2][i + 1] = min(dp[2][i + 1], dp[1][i])
		dp[2][i + 1] = min(dp[2][i + 1], dp[0][i])
ans = INF
for line in dp:
	ans = min(ans, line[-1])
print(ans)


import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	(n1, n2, n3) = nm()
	n = n1 + n2 + n3
	g1 = nl()
	g2 = nl()
	g3 = nl()
	f1 = [0] * (n + 1)
	f2 = [0] * (n + 1)
	f3 = [0] * (n + 1)
	for x in g1:
		f1[x] = 1
	for x in g2:
		f2[x] = 1
	for x in g3:
		f3[x] = 1
	for i in range(n):
		f1[i + 1] += f1[i]
		f2[i + 1] += f2[i]
		f3[i + 1] += f3[i]
	h12 = [f2[i] - f1[i] for i in range(n + 1)]
	h23 = [f3[i] - f2[i] for i in range(n + 1)]
	for i in range(n - 1, -1, -1):
		h23[i] = min(h23[i], h23[i + 1])
	ans = n1 + n2 + min((h12[i] + h23[i] for i in range(n + 1)))
	print(ans)
	return
solve()


(a, b, c) = [int(i) for i in input().split()]
l = [0 for i in range(a + b + c)]
arr1 = [int(i) for i in input().split()]
for i in arr1:
	l[i - 1] = 1
arr2 = [int(i) for i in input().split()]
for i in arr2:
	l[i - 1] = 2
arr3 = [int(i) for i in input().split()]
for i in arr3:
	l[i - 1] = 3
l1 = [0 for i in range(a + b + c + 1)]
for i in range(a + b + c):
	if l[i] == 1:
		l1[i + 1] = l1[i] - 1
	elif l[i] == 2:
		l1[i + 1] = l1[i] + 1
	else:
		l1[i + 1] = l1[i]
diff = [0 for i in range(a + b + c + 1)]
for i in range(a + b + c - 1, -1, -1):
	if l[i] == 2:
		diff[i] = diff[i + 1] + 1
	elif l[i] == 3:
		diff[i] = diff[i + 1] - 1
	else:
		diff[i] = diff[i + 1]
min_diff = [0 for i in range(a + b + c + 1)]
for i in range(a + b + c - 1, -1, -1):
	min_diff[i] = min(min_diff[i + 1], diff[i])
p = float('inf')
for i in range(a + b + c + 1):
	p = min(p, l1[i] + min_diff[i])
print(a + c + p)


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
(k1, k2, k3) = (int(i) for i in input().split())
n = k1 + k2 + k3
l = [0 for i in range(n)]
for i in range(3):
	l1 = [int(j) for j in input().split()]
	for j in l1:
		l[j - 1] = i
ans = 0
m = 0
for i in range(n):
	if l[i] <= 1:
		ans += 1
le = [0, 0, 0]
ri = [0, 0, 0]
for i in range(n):
	ri[l[i]] += 1
for i in range(n):
	le[l[i]] += 1
	ri[l[i]] -= 1
	m = max(m, le[0] - le[1])
	k = ri[0] + ri[1] + le[2] + le[0] - m
	ans = min(ans, k)
print(ans)


def main():
	import sys
	input = sys.stdin.readline
	(k1, k2, k3) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	dic = {}
	for a in A:
		dic[a] = 0
	for b in B:
		dic[b] = 1
	for c in C:
		dic[c] = 2
	N = k1 + k2 + k3
	dp = [[10 ** 9] * 3 for _ in range(N + 1)]
	dp[0][0] = 0
	dp[0][1] = 0
	dp[0][2] = 0
	for i in range(1, N + 1):
		dp[i][0] = min(dp[i][0], dp[i - 1][0] + (dic[i] != 0))
		dp[i][1] = min(dp[i][1], dp[i - 1][1] + (dic[i] != 1), dp[i - 1][0] + (dic[i] != 1))
		dp[i][2] = min(dp[i][2], dp[i - 1][2] + (dic[i] != 2), dp[i - 1][1] + (dic[i] != 2), dp[i - 1][0] + (dic[i] != 2))
	print(min(dp[-1]))
main()


class UnionFindVerSize:

	def __init__(self, N):
		self._parent = [n for n in range(0, N)]
		self._size = [1] * N
		self.group = N

	def find_root(self, x):
		if self._parent[x] == x:
			return x
		self._parent[x] = self.find_root(self._parent[x])
		stack = [x]
		while self._parent[stack[-1]] != stack[-1]:
			stack.append(self._parent[stack[-1]])
		for v in stack:
			self._parent[v] = stack[-1]
		return self._parent[x]

	def unite(self, x, y):
		gx = self.find_root(x)
		gy = self.find_root(y)
		if gx == gy:
			return
		self.group -= 1
		if self._size[gx] < self._size[gy]:
			self._parent[gx] = gy
			self._size[gy] += self._size[gx]
		else:
			self._parent[gy] = gx
			self._size[gx] += self._size[gy]

	def get_size(self, x):
		return self._size[self.find_root(x)]

	def is_same_group(self, x, y):
		return self.find_root(x) == self.find_root(y)
import sys, random, bisect
from collections import deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import permutations
from math import log, gcd
input = lambda : sys.stdin.buffer.readline()
mi = lambda : map(int, input().split())
li = lambda : list(mi())
k = li()
a = [li() for i in range(3)]
n = sum(k)
f = [0 for i in range(n + 2)]
g = [0 for i in range(n + 2)]
for i in range(k[0]):
	f[a[0][i]] -= 2
	g[a[0][i]] -= 1
for i in range(k[2]):
	f[a[2][i]] -= 1
	g[a[2][i]] -= 2
for i in range(1, n + 2):
	f[i] += f[i - 1]
for i in range(n, 0, -1):
	g[i] += g[i + 1]
for i in range(1, n + 2):
	f[i] += i
	g[i] -= i
for i in range(n, -1, -1):
	g[i] = min(g[i], g[i + 1])
res = min(n - k[0], n - k[2])
for l in range(n + 1):
	tmp = k[0] + k[2] + n + 1 + f[l] + g[l + 1]
	res = min(res, tmp)
print(res)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
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')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10)]
pp = [0] * 10

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

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = 0
	while left <= right:
		mid = (right + left) // 2
		if arr[mid][0] > key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res
(a, b, c) = map(int, input().split())
s = set(map(int, input().split()))
s1 = set(map(int, input().split()))
s2 = set(map(int, input().split()))
dp = [[0 for i in range(3)] for j in range(a + b + c + 1)]
for i in range(1, a + b + c + 1):
	dp[i][0] = dp[i - 1][0]
	dp[i][1] = min(dp[i - 1][1], dp[i - 1][0])
	dp[i][2] = min(dp[i - 1][1], dp[i - 1][0], dp[i - 1][2])
	if i in s:
		dp[i][1] += 1
		dp[i][2] += 1
	elif i in s1:
		dp[i][0] += 1
		dp[i][2] += 1
	else:
		dp[i][1] += 1
		dp[i][0] += 1
print(min(dp[-1]))


from sys import stdin, stdout
inf = 1000000000000007

def solve():
	(a1, b1, c1) = [int(i) for i in stdin.readline().split()]
	k = a1 + b1 + c1
	a = [0 for i in range(k + 1)]
	for i in stdin.readline().split():
		a[int(i)] = 0
	for i in stdin.readline().split():
		a[int(i)] = 1
	for i in stdin.readline().split():
		a[int(i)] = 2
	dp = [[inf for i in range(k + 1)] for j in range(3)]
	(dp[0][0], dp[1][0], dp[2][0]) = (0, 0, 0)
	for i in range(1, k + 1):
		for j in range(3):
			if a[i] == j:
				for l in range(0, j + 1):
					dp[j][i] = min(dp[j][i], dp[l][i - 1])
			else:
				for l in range(0, j + 1):
					dp[j][i] = min(dp[j][i], dp[l][i - 1] + 1)
	print(min(dp[0][k], dp[1][k], dp[2][k]))
solve()


(k1, k2, k3) = map(int, input().split())
s = [set(map(int, input().split())) for _ in range(3)]
inf = 10 ** 9
dp = [[inf] * 3 for _ in range(k1 + k2 + k3 + 1)]
dp[0][0] = 0
for i in range(1, k1 + k2 + k3 + 1):
	for j in range(3):
		for k in range(j, 3):
			dp[i][k] = min(dp[i][k], dp[i - 1][j] + (i not in s[k]))
print(min(dp[-1]))


import sys, os, io
import bisect
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(k1, k2, k3) = [int(i) for i in input().split()]
n = k1 + k2 + k3
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
v = [0] * n
for i in b:
	v[i - 1] = 1
for i in c:
	v[i - 1] = 2
dp = [[0] * 3 for i in range(n + 1)]
for i in range(1, n + 1):
	if v[i - 1] != 0:
		dp[i][0] = dp[i - 1][0] + 1
	else:
		dp[i][0] = dp[i - 1][0]
	if v[i - 1] != 1:
		dp[i][1] = min(dp[i - 1][:2]) + 1
	else:
		dp[i][1] = min(dp[i - 1][:2])
	if v[i - 1] != 2:
		dp[i][2] = min(dp[i - 1]) + 1
	else:
		dp[i][2] = min(dp[i - 1])
print(min(dp[n]))


(x, y, z) = map(int, input().split())
d = [[], [], []]
d[0] = list(map(int, input().split()))
d[1] = list(map(int, input().split()))
d[2] = list(map(int, input().split()))
dicto = [dict(), dict(), dict()]
dp = [[float('inf')] * (x + y + z + 1) for i in range(3)]
for i in range(3):
	for j in d[i]:
		dicto[i][j] = 1
dp[0][0] = 0
mini = 9999999999999
for i in range(1, x + y + z + 1):
	mini = 999999999999
	for j in range(3):
		for k in range(j + 1):
			mini = min(mini, dp[k][i - 1])
		if i not in dicto[j]:
			dp[j][i] = mini + 1
		else:
			dp[j][i] = mini
for i in range(3):
	mini = min(dp[0][x + y + z], dp[1][x + y + z], dp[2][x + y + z])
print(mini)


import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
from collections import defaultdict
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')
(k1, k2, k3) = map(int, input().split())
c = [dict(), dict(), dict()]
a = [[], [], []]
a[0] = list(map(int, input().split()))
a[1] = list(map(int, input().split()))
a[2] = list(map(int, input().split()))
for i in range(3):
	for j in a[i]:
		c[i][j] = 1
dp = [[float('inf') for j in range(3)] for i in range(k1 + k2 + k3 + 1)]
dp[0] = [0, 0, 0]
for i in range(1, k1 + k2 + k3 + 1):
	for j in range(3):
		for k in range(j, 3):
			dp[i][k] = min(dp[i][k], dp[i - 1][j] + (1 if i not in c[k] else 0))
print(min(dp[k1 + k2 + k3]))


import sys
input = sys.stdin.readline
(K1, K2, K3) = map(int, input().split())
N = K1 + K2 + K3
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
state = []
P = []
ind = 0
for b in B:
	while ind < K3 and C[ind] < b:
		state.append(1)
		P.append(C[ind])
		ind += 1
	state.append(0)
	P.append(b)
while ind < K3:
	state.append(1)
	P.append(C[ind])
	ind += 1
dp = [[0, 0] for _ in range(K2 + K3 + 1)]
for i in reversed(range(K2 + K3)):
	if state[i] == 0:
		dp[i][0] = min(dp[i + 1][0], dp[i + 1][1])
		dp[i][1] = dp[i + 1][1] + 1
	else:
		dp[i][0] = min(dp[i + 1][0], dp[i + 1][1]) + 1
		dp[i][1] = dp[i + 1][1]
ans = 10 ** 14
indp = 0
inda = 0
for n in range(N + 1):
	while indp < K3 + K2 and P[indp] <= n:
		indp += 1
	while inda < K1 and A[inda] <= n:
		inda += 1
	ans = min(ans, indp + (K1 - inda) + min(dp[indp]))
print(ans)


(k1, k2, k3) = map(int, input().split())
n = k1 + k2 + k3
a = [0] * n
input()
for x in map(int, input().split()):
	a[x - 1] = 1
for x in map(int, input().split()):
	a[x - 1] = 2
prev = [0, 0, 0]
for (i, x) in enumerate(a):
	new = [0, 0, 0]
	new[0] = prev[0] + (x != 0)
	new[1] = min(prev[0], prev[1]) + (x != 1)
	new[2] = min(prev) + (x != 2)
	prev = new
print(min(prev))


import types
_atcoder_code = '\n# Python port of AtCoder Library.\n__all__ = ["string","lazysegtree","convolution","maxflow","modint"\n    ,"mincostflow","segtree","_scc","_math","math","dsu","twosat","fenwicktree","scc","_bit","lca","unverified","graph","matrix","algebra","combinatorics"]\n__version__ = \'0.0.1\'\n'
atcoder = types.ModuleType('atcoder')
exec(_atcoder_code, atcoder.__dict__)
_atcoder__bit_code = '\ndef _ceil_pow2(n: int) -> int:\n    x = 0\n    while (1 << x) < n:\n        x += 1\n\n    return x\n\n\ndef _bsf(n: int) -> int:\n    x = 0\n    while n % 2 == 0:\n        x += 1\n        n //= 2\n\n    return x\n'
atcoder._bit = types.ModuleType('atcoder._bit')
exec(_atcoder__bit_code, atcoder._bit.__dict__)
_atcoder_segtree_code = "\nimport typing\n\n# import atcoder._bit\n\n\nclass SegTree:\n \n    '''\n    Segment Tree Library.\n    op(S,S) -> S\n    e = Identity element\n    \n    SegTree(op,e,n) := Initialized by [e]*(n)\n    SegTree(op,e,vector) := Initialized by vector\n    '''\n\n    def __init__(self,\n                 op: typing.Callable[[typing.Any, typing.Any], typing.Any],\n                 e: typing.Any,\n                 v: typing.Union[int, typing.List[typing.Any]]) -> None:\n        self._op = op\n        self._e = e\n\n        if isinstance(v, int):\n            v = [e] * v\n\n        self._n = len(v)\n        self._log = atcoder._bit._ceil_pow2(self._n)\n        self._size = 1 << self._log\n        self._d = [e] * (2 * self._size)\n\n        for i in range(self._n):\n            self._d[self._size + i] = v[i]\n        for i in range(self._size - 1, 0, -1):\n            self._update(i)\n\n    def set(self, p: int, x: typing.Any) -> None:\n        '''\n        a[p] -> x in O(logN).\n        '''\n        assert 0 <= p < self._n\n\n        p += self._size\n        self._d[p] = x\n        for i in range(1, self._log + 1):\n            self._update(p >> i)\n\n    def increment(self, p: int, x : typing.Any) -> None:\n        '''\n        a[p] -> a[p] + x in O(logN).\n        '''\n        assert 0 <= p < self._n\n\n        p += self._size\n        self._d[p] += x\n        for i in range(1,self._log + 1):\n            self._update(p >> i)\n        \n    def get(self, p: int) -> typing.Any:\n        '''\n        return a[p] in O(1).\n        '''\n        assert 0 <= p < self._n\n\n        return self._d[p + self._size]\n\n    def prod(self, left: int, right: int) -> typing.Any:\n        '''\n        return op(a[l...r)) in O(logN).\n        '''\n        assert 0 <= left <= right <= self._n\n        sml = self._e\n        smr = self._e\n        left += self._size\n        right += self._size\n\n        while left < right:\n            if left & 1:\n                sml = self._op(sml, self._d[left])\n                left += 1\n            if right & 1:\n                right -= 1\n                smr = self._op(self._d[right], smr)\n            left >>= 1\n            right >>= 1\n\n        return self._op(sml, smr)\n\n    def all_prod(self) -> typing.Any:\n        return self._d[1]\n\n    def max_right(self, left: int,\n                  f: typing.Callable[[typing.Any], bool]) -> int:\n        '''\n        let f(S) -> bool and l is const.\n        return maximum r for which f(op[l...r)) == true is satisfied, in O(logN).\n        '''\n        assert 0 <= left <= self._n\n        # assert f(self._e)\n\n        if left == self._n:\n            return self._n\n\n        left += self._size\n        sm = self._e\n\n        first = True\n        while first or (left & -left) != left:\n            first = False\n            while left % 2 == 0:\n                left >>= 1\n            if not f(self._op(sm, self._d[left])):\n                while left < self._size:\n                    left *= 2\n                    if f(self._op(sm, self._d[left])):\n                        sm = self._op(sm, self._d[left])\n                        left += 1\n                return left - self._size\n            sm = self._op(sm, self._d[left])\n            left += 1\n\n        return self._n\n\n    def min_left(self, right: int,\n                 f: typing.Callable[[typing.Any], bool]) -> int:\n        '''\n        let f(S) -> bool and r is const.\n        return minimum l for which f(op[l...r)) == true is satisfied, in O(logN).\n        '''\n\n        assert 0 <= right <= self._n\n        # assert f(self._e)\n\n        if right == 0:\n            return 0\n\n        right += self._size\n        sm = self._e\n\n        first = True\n        while first or (right & -right) != right:\n            first = False\n            right -= 1\n            while right > 1 and right % 2:\n                right >>= 1\n            if not f(self._op(self._d[right], sm)):\n                while right < self._size:\n                    right = 2 * right + 1\n                    if f(self._op(self._d[right], sm)):\n                        sm = self._op(self._d[right], sm)\n                        right -= 1\n                return right + 1 - self._size\n            sm = self._op(self._d[right], sm)\n\n        return 0\n\n    def _update(self, k: int) -> None:\n        self._d[k] = self._op(self._d[2 * k], self._d[2 * k + 1])\n"
atcoder.segtree = types.ModuleType('atcoder.segtree')
atcoder.segtree.__dict__['atcoder'] = atcoder
atcoder.segtree.__dict__['atcoder._bit'] = atcoder._bit
exec(_atcoder_segtree_code, atcoder.segtree.__dict__)
SegTree = atcoder.segtree.SegTree
import sys

def input():
	return sys.stdin.readline().rstrip()
DXY = [(0, -1), (1, 0), (0, 1), (-1, 0)]

def make_3_2_lst(a):
	n = len(a)
	x = [0] * (n + 1)
	for i in range(1, n + 1):
		x[i] = x[i - 1] + (a[i - 1] == 3)
	y = [0] * (n + 1)
	for i in range(1, n + 1):
		y[i] = y[i - 1] + (a[-i] == 2)
	for i in range(n + 1):
		x[i] += y[n - i]
	return x

def make_2_1_lst(a):
	n = len(a)
	x = [0] * (n + 1)
	for i in range(1, n + 1):
		x[i] = x[i - 1] + (a[i - 1] == 2)
	y = [0] * (n + 1)
	for i in range(1, n + 1):
		y[i] = y[i - 1] + (a[-i] == 1)
	for i in range(n + 1):
		x[i] += y[n - i]
	return x
INF = 1 << 32

def main():
	ns = tuple(map(int, input().split()))
	a = [0] * sum(ns)
	for i in range(3):
		lst = list(map(int, input().split()))
		for v in lst:
			a[v - 1] = i + 1
	n = sum(ns)
	Y = SegTree(lambda x, y: min(x, y), INF, make_3_2_lst(a))
	X = make_2_1_lst(a)
	ans = min((X[i] + Y.prod(i, n + 1) for i in range(n + 1)))
	print(ans)
	return 0
main()


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def main():
	(k1, k2, k3) = map(int, input().split())
	n = k1 + k2 + k3
	problems = [0] * (n + 1)
	input()
	for i in range(1, 3):
		for x in map(int, input().split()):
			problems[x] = i
	inf = 10 ** 9
	dp = [[inf] * 3 for _ in range(n + 1)]
	dp[0] = [0, 0, 0]
	for i in range(1, n + 1):
		for j in range(3):
			for k in range(j, 3):
				dp[i][k] = min(dp[i][k], dp[i - 1][j] + (1 if problems[i] != k else 0))
	print(min(dp[-1]))
main()