#include <bits/stdc++.h>
using namespace std;
void no() {
  cout << "-1\n";
  exit(0);
}
void yes() { cout << "YES\n"; }
const int maxn = 2005;
int a[maxn][maxn];
int row_flipped[maxn][maxn], col_flipped[maxn][maxn];
vector<int> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
void solve() {
  int n;
  cin >> n;
  for (int i = (int)1; i < (int)n + 1; i++)
    for (int j = (int)1; j < (int)n + 1; j++) {
      char x;
      cin >> x;
      if (x == '1') a[i][j] = 1;
    }
  int ans = 0;
  for (int i = (int)1; i < (int)n + 1; i++) {
    for (int j = (int)n; j >= (int)i + 1; j--) {
      42;
      int flip = 0;
      if (row_flipped[i][j + 1]) flip ^= 1;
      if (col_flipped[i - 1][j]) flip ^= 1;
      int flip_with = (flip != a[i][j]);
      ans += flip_with;
      row_flipped[i][j] = row_flipped[i][j + 1] ^ flip_with;
      col_flipped[i][j] = col_flipped[i - 1][j] ^ flip_with;
    }
  }
  for (int i = (int)n; i >= (int)1; i--) {
    for (int j = (int)1; j < (int)i; j++) {
      int flip = 0;
      if (row_flipped[i][j - 1]) flip ^= 1;
      if (col_flipped[i + 1][j]) flip ^= 1;
      int flip_with = (flip != a[i][j]);
      ans += flip_with;
      row_flipped[i][j] = row_flipped[i][j - 1] ^ flip_with;
      col_flipped[i][j] = col_flipped[i + 1][j] ^ flip_with;
    }
  }
  for (int i = (int)1; i < (int)n + 1; i++) {
    int flip = 0;
    int j = i;
    flip = row_flipped[i][j + 1] ^ row_flipped[i][j - 1] ^
           col_flipped[i + 1][j] ^ col_flipped[i - 1][j];
    42;
    if (flip != a[i][i]) ans++;
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  for (int tc = 1; tc <= t; tc++) {
    solve();
  }
}
