#include <bits/stdc++.h>
using namespace std;
vector<int> G[2 * 100000 + 5];
int ans = 0;
int U[2005][2005];
int D[2005][2005];
int L[2005][2005];
int R[2005][2005];
char S[2005][2005];
int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    scanf(" %s", S[i] + 1);
  }
  for (int i = N; i > 1; i--) {
    int x = i;
    int y = 1;
    while (x <= N) {
      if ((U[x][y] ^ R[x][y]) != (S[x][y] - '0')) {
        U[x][y] ^= 1;
        R[x][y] ^= 1;
        ++ans;
      }
      U[x - 1][y] ^= U[x][y];
      R[x][y + 1] ^= R[x][y];
      ++x;
      ++y;
    }
  }
  for (int i = 1; i < N; i++) {
    int x = i;
    int y = N;
    while (x >= 1) {
      if ((L[x][y] ^ D[x][y]) != (S[x][y] - '0')) {
        L[x][y] ^= 1;
        D[x][y] ^= 1;
        ++ans;
      }
      D[x + 1][y] ^= D[x][y];
      L[x][y - 1] ^= L[x][y];
      --x;
      --y;
    }
  }
  for (int i = 1; i <= N; ++i) {
    ans += ((S[i][i] - '0') != (L[i][i] ^ R[i][i] ^ U[i][i] ^ D[i][i]));
  }
  cout << ans;
}
