#include <bits/stdc++.h>
using namespace std;
const int N = 150;
struct Node {
  string s[N];
} node[4];
int n;
int func(int i1, int i2, int i3, int i4) {
  string s[2 * N];
  for (int i = 0; i < n; i++) {
    s[i] = node[i1].s[i] + node[i2].s[i];
    s[i + n] = node[i3].s[i] + node[i4].s[i];
  }
  char flag = (s[0][0] == '0' ? '0' : '1');
  int res = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < s[i].size(); j++) {
        if (j % 2 == 0 && s[i][j] != flag) res++;
        if (j % 2 != 0 && s[i][j] == flag) res++;
      }
    } else {
      for (int j = 0; j < s[i].size(); j++) {
        if (j % 2 == 0 && s[i][j] == flag) res++;
        if (j % 2 != 0 && s[i][j] != flag) res++;
      }
    }
  }
  s[0][0] = (s[0][0] == '0' ? '1' : '0');
  flag = (s[0][0] == '0' ? '0' : '1');
  int res1 = 1;
  for (int i = 0; i < 2 * n; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < s[i].size(); j++) {
        if (j % 2 == 0 && s[i][j] != flag) res1++;
        if (j % 2 != 0 && s[i][j] == flag) res1++;
      }
    } else {
      for (int j = 0; j < s[i].size(); j++) {
        if (j % 2 == 0 && s[i][j] == flag) res1++;
        if (j % 2 != 0 && s[i][j] != flag) res1++;
      }
    }
  }
  return min(res, res1);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (cin >> n) {
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < n; j++) {
        cin >> node[i].s[j];
      }
    }
    int ans = INT_MAX;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        for (int h = 0; h < 4; h++) {
          for (int k = 0; k < 4; k++) {
            if (i == j || i == h || i == k || j == h || j == k || h == k)
              continue;
            ans = min(ans, func(i, j, h, k));
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
