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.

Difficulty: interview

Starter code:

Solutions:
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]))

3

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)


###############################################################################
# AUXILIARY FUNCTIONS

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)


def __starting_point():
    main()

__starting_point()

import sys
input = sys.stdin.readline
K1, K2, K3 = list(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)


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
#ilenie2wprawo = [0] * n
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
#	ilenie2wprawo[i] = ilenie2wprawo[i+1]
	ilenie3wprawo[i] = ilenie3wprawo[i+1]
	ilenie1wlewo[i] = ilenie1wlewo[i+1]
#	if assign[i] != 2:
#		ilenie2wprawo[i] += 1
	if assign[i] != 3:
		ilenie3wprawo[i] += 1
	if assign[i + 1] != 1:
		ilenie1wlewo[i] -= 1
#print(assign)
#print(ilenie1wlewo, ilenie3wprawo)
odp = [0] * (n + 1)
# odp[i] to odp zakladajac ze dokladnie i pierwszych nalezy do pierwszego
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(odp)
print(min(odp))

#!/usr/bin/env python3
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

# seen ith, state(a hold, b hold, c hold)
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)

# inf = open('input.txt', 'r')
# reader = (map(int, line.split()) for line in inf)
# k1, k2, k3 = next(reader)
# a = list(next(reader))
# b = list(next(reader))
# c = list(next(reader))

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(abc)
print(n - LIS(abc, n))

# inf.close()


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
input = sys.stdin.readline

k1,k2,k3=list(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())
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))

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(a)
# print(dp)
print(n-max(dp))

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()

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)#[::-1]

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))

#1 5 1
#6
#5 1 2 4 7
#3

#2 1 3
#5 6
#4
#1 2 3


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()

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 = 1e9
for i in range(n + 1):
	if l[i] + r_cum_min[i] < answer:
		answer = l[i] + r_cum_min[i]

# print(l)
# print(r)

print(answer)


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 = list(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 = 1e9
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)


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 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)


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)

# -*- coding: utf-8 -*-
"""
Created on Fri Nov 22 20:14:03 2019

@author: Tejasvi Sharma
"""

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*1e5+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]
#        print(str(i)+"->")
#        print(stateStorage[i%2][0],stateStorage[i%2][1],stateStorage[i%2][2])
    return min(stateStorage[0][0],stateStorage[0][1],stateStorage[0][2])
        

#def recF(index, state):
#    if stateStorage[index][state-1]!=inf:
#        return stateStorage[index][state-1]
#    val = 0
#    if state==1:
#        if B[index]==1:
#            val += recF(index+1, state)
#        elif B[index]==2:
#            val += min(recF(index+1,state)+1, recF(index+1,state=2))
#        else:
#            val += min(recF(index+1,state)+1, recF(index+1,state=3))
#    elif state==2:
#        if B[index]==1:
#            val += recF(index+1, state)+1
#        elif B[index]==2:
#            val += recF(index+1, state)
#        else:
#            val += min(recF(index+1,state)+1, recF(index+1,state=3))
#    elif state==3:
#        if B[index]==3:
#            val += recF(index+1, state)
#        else:
#            val += recF(index+1, state)+1
#            
#    stateStorage[index][state-1]=val
#    return stateStorage[index][state-1]

        
ans = fillMatrix(n)
print(ans)


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))



def solve(arr):
    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:2])
            dp[0] += 1
            dp[2] += 1
        if i == 3:
            dp[2] = min(dp)
            dp[0] += 1
            dp[1] += 1

    return min(dp)


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(arr))
__starting_point()

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()

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]))
#for j in range(3):
 #   for i in range(n+1):
  #      print(dp[i][j],end=" ")
   # print()

print(min(dp[n]))