#include <bits/stdc++.h>
using namespace std;
char a[2048][2048];
int flagr[2048], flagc[2048];
int n, ans = 0;
void print() {
  cout << endl;
  cout << "==========" << endl;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) cout << a[i][j];
    cout << endl;
  }
  cout << endl;
}
void solve() {
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j > i; j--) {
      if ((a[i][j] - '0' + flagr[i] + flagc[j]) & 1) {
        a[i][j] = '0';
        flagc[j]++, flagr[i]++, ans++;
      }
      a[i][j] = '0';
    }
  }
  for (int i = 0; i < n; i++) {
    a[i][i] = (a[i][i] - '0' + flagr[i] + flagc[i]) % 2 + 48;
  }
  memset(flagr, 0, sizeof(flagr));
  memset(flagc, 0, sizeof(flagc));
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < i; j++) {
      if ((a[i][j] - '0' + flagr[i] + flagc[j]) & 1) {
        flagc[j]++, flagr[i]++, ans++;
      }
      a[i][j] = '0';
    }
  }
  for (int i = 0; i < n; i++)
    if ((a[i][i] - '0' + flagr[i] + flagc[i]) % 2) ans++;
}
int main() {
  int i, j, k, l;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", a[i]);
  }
  solve();
  printf("%d\n", ans);
  return 0;
}
