import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
void ERR(T)(in T x) { stderr.writeln(x); }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	long[][3] abc;
	abc[0] = RDR.split.to!(long[]);
	abc[1] = RDR.split.to!(long[]);
	abc[2] = RDR.split.to!(long[]);
	abc[0].sort();
	abc[1].sort();
	abc[2].sort();

	auto dp = new long[][](3, N+1);
	fill(dp[0], 1);
	foreach (i; 0..2)
	{
		long j, k;
		while (k < N)
		{
			if (j >= N)
			{
				dp[i+1][k+1] = dp[i+1][k];
				++k;
				continue;
			}
			else if (abc[i][j] >= abc[i+1][k])
			{
				dp[i+1][k+1] = dp[i+1][k];
				++k;
				continue;
			}

			dp[i+1][k] += dp[i][j];
			++j;
		}
	}

	ERR(dp);
	writeln(dp[$-1][0..N].sum);
	stdout.flush();
}