#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
long long mulmod(long long a, long long b, long long MOD) {
  if (b == 0) return 0;
  long long res = mulmod(a, b >> 1, MOD);
  res += res;
  res %= MOD;
  return (b & 1) ? (a + res) % MOD : res;
}
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  char a[2013][2013];
  int v[2013], h[2013];
  int vv[2013], hh[2013];
  for (int i = 0; i < n; i++) {
    v[i] = 0;
    h[i] = 0;
    vv[i] = 0;
    hh[i] = 0;
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  int ans = 0;
  for (int i = n - 1; i >= 1; i--) {
    for (int j = 0; j < i; j++) {
      if (a[i][j] == '1') {
        if (((v[i] + h[j]) & 1) == 0) {
          v[i]++;
          h[j]++;
          ans++;
        }
      } else {
        if (((v[i] + h[j]) & 1) != 0) {
          v[i]++;
          h[j]++;
          ans++;
        }
      }
    }
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = n - 1; j > i; j--) {
      if (a[i][j] == '1') {
        if (((vv[i] + hh[j]) & 1) == 0) {
          vv[i]++;
          hh[j]++;
          ans++;
        }
      } else {
        if (((vv[i] + hh[j]) & 1) != 0) {
          vv[i]++;
          hh[j]++;
          ans++;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i][i] == '1') {
      if (((vv[i] + hh[i] + v[i] + h[i]) & 1) == 0) {
        ans++;
      }
    } else {
      if (((vv[i] + hh[i] + v[i] + h[i]) & 1) != 0) {
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
