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

void main()
{
  int part_amount = to!int(chomp(readln()));
  int[][3] parts;
  for(int i = 0; i < 3; i++) {
    string[] input = split(readln());
    for(int j = 0; j < part_amount; j++) {
      parts[i] ~= to!int(input[j]);
    }
  }
  int count = 0;
  for(int i = 0; i < part_amount; i++) {
    int top = parts[0][i];
    for(int j = 0; j < part_amount; j++) {
      int middle = parts[1][j];
      for(int k = 0; k < part_amount; k++) {
        int bottom = parts[2][k];
        if(top < middle && middle < bottom) {
          count++;
        }
      }
    }
  }
  writeln(count);
}
