#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  int m;
  vector<int> w_b(4);
  vector<int> w_w(4);
  for (int i = 0; i < 4; ++i) {
    w_b[i] = 0;
    w_w[i] = 0;
  }
  for (int i = 0; i < 4; ++i) {
    for (int j = 1; j <= n; j++) {
      cin >> s;
      m = s.size();
      if (j % 2 == 0) {
        for (int u = 1; u <= m; ++u) {
          if (s[u - 1] == '0' && u % 2 == 0) {
            w_b[i]++;
          }
          if (s[u - 1] == '1' && u % 2 == 0) {
            w_w[i]++;
          }
          if (s[u - 1] == '0' && u % 2 == 1) {
            w_w[i]++;
          }
          if (s[u - 1] == '1' && u % 2 == 1) {
            w_b[i]++;
          }
        }
      } else {
        for (int u = 1; u <= m; ++u) {
          if (s[u - 1] == '0' && u % 2 == 0) {
            w_w[i]++;
          }
          if (s[u - 1] == '1' && u % 2 == 0) {
            w_b[i]++;
          }
          if (s[u - 1] == '0' && u % 2 == 1) {
            w_b[i]++;
          }
          if (s[u - 1] == '1' && u % 2 == 1) {
            w_w[i]++;
          }
        }
      }
    }
  }
  int res = 0;
  res =
      min(w_w[0] + w_w[1] + w_b[2] + w_b[3], w_w[0] + w_w[2] + w_b[1] + w_b[3]);
  res = min(res, w_w[0] + w_w[3] + w_b[2] + w_b[1]);
  res = min(res, w_w[2] + w_w[3] + w_b[0] + w_b[1]);
  res = min(res, w_w[1] + w_w[3] + w_b[0] + w_b[2]);
  res = min(res, w_w[2] + w_w[1] + w_b[0] + w_b[3]);
  cout << res;
  return 0;
}
