#include <bits/stdc++.h>
using namespace std;
int n, ans = 0;
int t[2000][2000];
vector<int> b(2000), d(2000);
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) {
      t[i][j] = s[j] == '1';
    }
    d[i] = t[i][i];
  }
  for (int i = 0; i < n; i++) {
    int now = 0;
    for (int j = n - 1; j > i; j--) {
      if (t[i][j] ^ now ^ b[j]) {
        ans++;
        now ^= 1;
        b[j] ^= 1;
        d[j] ^= 1;
        d[i] ^= 1;
      }
    }
  }
  b.assign(2000, 0);
  for (int i = n - 1; i > 0; i--) {
    int now = 0;
    for (int j = 0; j < i; j++) {
      if (t[i][j] ^ now ^ b[j]) {
        ans++;
        now ^= 1;
        b[j] ^= 1;
        d[j] ^= 1;
        d[i] ^= 1;
      }
    }
  }
  for (int i = 0; i < n; i++) ans += d[i];
  cout << ans;
  return 0;
}
