#include <bits/stdc++.h>
char a[2010][2010];
int row[2][2010], col[2][2010], ans;
void updata(int k1, int i, int k2, int j) {
  if ((a[i][j] ^ row[k1][i] ^ col[k2][j]) == 1) {
    ++ans;
    row[k1][i] ^= 1;
    col[k2][j] ^= 1;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", a[i]);
    for (int j = 0; j < n; ++j) {
      a[i][j] -= '0';
    }
  }
  for (int k = 0; k < n / 2; ++k) {
    int end = n - k - 1;
    for (int i = k, j = end; j > k; --j) {
      updata(0, i, 0, j);
    }
    for (int i = k + 1, j = end; i < end; ++i) {
      updata(0, i, 0, j);
    }
    for (int i = end, j = k; i > k; --i) {
      updata(1, i, 1, j);
    }
    for (int i = end, j = k + 1; j < end; ++j) {
      updata(1, i, 1, j);
    }
    if ((a[k][k] ^ col[0][k] ^ col[1][k] ^ row[0][k] ^ row[1][k]) == 1) {
      ++ans;
    }
    if ((a[end][end] ^ col[0][end] ^ col[1][end] ^ row[0][end] ^ row[1][end]) ==
        1) {
      ++ans;
    }
  }
  int mid = n / 2;
  if (n % 2 && ((a[mid][mid] ^ col[0][mid] ^ col[1][mid] ^ row[0][mid] ^
                 row[1][mid]) == 1)) {
    ++ans;
  }
  printf("%d\n", ans);
  return 0;
}
