#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int N = 2e3 + 10;
int n, a[N][N], invr[N], invc[N];
char s[N];
int solve() {
  int ans = 0;
  for (auto phase = 1; phase >= 0; phase--) {
    memset(invr, 0, sizeof(invr));
    memset(invc, 0, sizeof(invc));
    for (int sel = 0, sym = n - 1; sel <= sym; sel++, sym--) {
      for (auto i = sym; i >= sel + phase; i--)
        if (a[i][sel] ^ invc[sel] ^ invr[i]) {
          invr[i] ^= 1;
          invc[sel] ^= 1;
          ans++;
        }
      for (auto j = sel + 1; j <= sym - phase; j++)
        if (a[sym][j] ^ invr[sym] ^ invc[j]) {
          invc[j] ^= 1;
          invr[sym] ^= 1;
          ans++;
        }
    }
    for (auto i = 0; i < n; i++)
      if (invc[i] ^ invr[i]) a[i][i] ^= 1;
    for (auto i = 0; i < n; i++)
      for (auto j = i; j < n; j++) swap(a[i][j], a[j][i]);
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (auto i = 0; i < n; i++) {
    scanf("\n%s", s);
    for (auto j = 0; j < n; j++) a[i][j] = s[j] - '0';
  }
  cout << solve();
}
