#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2007;
int i, j, k, n, m, t, x, y, cnt;
bool mp[MAXN][MAXN], mkr[MAXN][MAXN], mkc[MAXN][MAXN];
char c[MAXN];
void changeDiagonalLine(int x, int y) {
  bool mk;
  mkr[x][y] = mkr[x][y - 1] ^ mkr[x][y + 1];
  mkc[x][y] = mkc[x + 1][y] ^ mkc[x - 1][y];
  mk = mkr[x][y] ^ mkc[x][y];
  if (mk ^ mp[x][y]) {
    cnt++;
    mkr[x][y] ^= 1;
    mkc[x][y] ^= 1;
  }
}
void changeRightTop(int x, int y) {
  bool mk;
  mkr[x][y] = mkr[x][y + 1];
  mkc[x][y] = mkc[x - 1][y];
  mk = mkr[x][y] ^ mkc[x][y];
  if (mk ^ mp[x][y]) {
    cnt++;
    mkr[x][y] ^= 1;
    mkc[x][y] ^= 1;
  }
}
void changeLeftBottom(int x, int y) {
  bool mk;
  mkr[x][y] = mkr[x][y - 1];
  mkc[x][y] = mkc[x + 1][y];
  mk = mkr[x][y] ^ mkc[x][y];
  if (mk ^ mp[x][y]) {
    cnt++;
    mkr[x][y] ^= 1;
    mkc[x][y] ^= 1;
  }
}
int main() {
  while (~scanf("%d", &n)) {
    memset(mp, 0, sizeof(mp));
    memset(mkr, 0, sizeof(mkr));
    memset(mkc, 0, sizeof(mkc));
    for (i = 1; i <= n; i++) {
      scanf("%s", &c);
      for (j = 0; j < n; j++) {
        mp[i][j + 1] = c[j] - '0';
      }
    }
    cnt = 0;
    for (i = n; i > (n + 1) / 2; i--) {
      changeLeftBottom(i, n + 1 - i);
      for (j = n + 2 - i; j < i; j++) {
        changeLeftBottom(i, j);
      }
      for (k = i - 1; k > n + 1 - i; k--) {
        changeLeftBottom(k, n + 1 - i);
      }
    }
    for (i = 1; i <= n / 2; i++) {
      changeRightTop(i, n + 1 - i);
      for (j = n - i; j > i; j--) {
        changeRightTop(i, j);
      }
      for (k = i + 1; k < n + 1 - i; k++) {
        changeRightTop(k, n + 1 - i);
      }
    }
    for (i = 1; i <= n; i++) {
      changeDiagonalLine(i, i);
    }
    cout << cnt << endl;
  }
  return 0;
}
