#include <bits/stdc++.h>
using namespace std;
const int maxN = 2332;
int a[maxN][maxN], fl[maxN], n, ans;
string s[maxN];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < n; j++) a[i][j] = s[i][j] - '0';
  }
  for (int i = 0; i < n; i++) {
    bool now = 0;
    for (int j = n - 1; j >= i; j--) {
      a[i][j] ^= now;
      a[i][j] ^= fl[j];
      fl[j] ^= a[i][j];
      now ^= a[i][j];
      ans += a[i][j] * (i != j);
    }
  }
  fill(fl, fl + maxN, 0);
  for (int i = n - 1; i + 1; i--) {
    bool now = 0;
    for (int j = 0; j <= i; j++) {
      a[i][j] ^= now;
      a[i][j] ^= fl[j];
      fl[j] ^= a[i][j];
      now ^= a[i][j];
      ans += a[i][j];
    }
  }
  cout << ans << endl;
  cin >> n;
}
