#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2241;
char a[MaxN][MaxN];
int n, display[MaxN][MaxN];
bool propagateDown[MaxN][MaxN], propagateLeft[MaxN][MaxN];
bool propagateUp[MaxN][MaxN], propagateRight[MaxN][MaxN];
int main() {
  cin.sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> a[i][j];
  int diff = n - 1, ans = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 1; j + diff <= n; j++) {
      display[j][j + diff] %= 2;
      if (propagateDown[j][j + diff]) {
        display[j + 1][j + diff]++;
        propagateDown[j + 1][j + diff] ^= 1;
      }
      if (propagateLeft[j][j + diff]) {
        display[j][j + diff - 1]++;
        propagateLeft[j][j + diff - 1] ^= 1;
      }
      if (display[j][j + diff] != a[j][j + diff] - '0') {
        display[j + 1][j + diff]++;
        display[j][j + diff - 1]++;
        propagateDown[j + 1][j + diff] ^= 1;
        propagateLeft[j][j + diff - 1] ^= 1;
        ++ans;
      }
      display[j + diff][j] %= 2;
      if (propagateUp[j + diff][j]) {
        display[j + diff - 1][j]++;
        propagateUp[j + diff - 1][j] ^= 1;
      }
      if (propagateRight[j + diff][j]) {
        display[j + diff][j + 1]++;
        propagateRight[j + diff][j + 1] ^= 1;
      }
      if (display[j + diff][j] != a[j + diff][j] - '0') {
        display[j + diff - 1][j]++;
        display[j + diff][j + 1]++;
        propagateUp[j + diff - 1][j] ^= 1;
        propagateRight[j + diff][j + 1] ^= 1;
        ans++;
      }
    }
    diff--;
  }
  for (int i = 1; i <= n; i++)
    if (display[i][i] % 2 != a[i][i] - '0') ans++;
  cout << ans << endl;
  return 0;
}
