#include <bits/stdc++.h>
using namespace std;
const long long LINF = ~(((long long)0x1) << 63) / 2;
const int INF = 0X3F3F3F3F;
const double eps = 1e-7;
int a[2200][2200];
int c[2200];
int main() {
  int n, i, j, k;
  string s;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s;
    for (j = 0; j < n; j++) a[i][j] = s[j] - '0';
  }
  int ans = 0;
  for (i = 0; i < n; i++) {
    int now = 0;
    for (j = n - 1; j > i; j--)
      if (a[i][j] ^ c[j] ^ now) {
        now ^= 1;
        c[j] ^= 1;
        a[i][i] ^= 1;
        a[j][j] ^= 1;
        ans++;
      }
  }
  memset(c, 0, sizeof(c));
  for (j = 0; j < n; j++) {
    int now = 0;
    for (i = n - 1; i > j; i--)
      if (a[i][j] ^ c[i] ^ now) {
        now ^= 1;
        c[i] ^= 1;
        a[i][i] ^= 1;
        a[j][j] ^= 1;
        ans++;
      }
  }
  for (i = 0; i < n; i++)
    if (a[i][i]) ans++;
  cout << ans << endl;
  return 0;
}
