import std.algorithm,
       std.string,
       std.stdio,
       std.range,
       std.conv;

void main() {
  string N = readln.chomp;
  auto A = readln.chomp.split.to!(ulong[]).sort!"a<b",
       B = readln.chomp.split.to!(ulong[]).sort!"a<b",
       C = readln.chomp.split.to!(ulong[]).sort!"a<b";
  ulong ans;

  foreach (b; B) {
    ans += A.lowerBound(b).length * C.upperBound(b).length;
  }

  writeln(ans);
}
