#include <bits/stdc++.h>
using namespace std;
long long max(long long x, long long y) { return x > y ? x : y; }
long long min(long long x, long long y) { return x < y ? x : y; }
void _(long long& a, long long b) {
  a = (a % 1000000007 + b % 1000000007) % 1000000007;
  a = (a + 1000000007) % 1000000007;
}
long long cl(long long a, long long b) { return (a / b) + (!(!(a % b))); }
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  char a[n][n];
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }
  long long b[n], c[n];
  long long dans[n];
  for (long long i = 0; i < n; ++i) {
    b[i] = c[i] = 0;
    dans[i] = 0;
  }
  long long ans = 0;
  for (long long i = n - 1; i > 0; i--) {
    long long x = i;
    for (long long j = 0; x < n; j++, x++) {
      if (((a[x][j] - '0') & 1) != ((b[x] + c[j]) & 1)) {
        ans++;
        b[x]++;
        c[j]++;
        dans[x]++;
        dans[j]++;
      }
    }
  }
  for (long long i = 0; i < n; ++i) {
    b[i] = c[i] = 0;
  }
  for (long long i = n - 1; i > 0; i--) {
    long long x = i;
    for (long long j = 0; x < n; j++, x++) {
      if (((a[j][x] - '0') & 1) != ((b[j] + c[x]) & 1)) {
        ans++;
        b[j]++;
        c[x]++;
        dans[x]++;
        dans[j]++;
      }
    }
  }
  for (long long i = 0; i < n; ++i) {
    dans[i] &= 1;
    if (dans[i] != (a[i][i] - '0')) ans++;
  }
  cout << ans;
}
