#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 100;
int dp[maxn];
int q[maxn];
int main() {
  int n;
  cin >> n;
  string arrey[n];
  for (int i = 0; i < n; i++) cin >> arrey[i];
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    int c = 0;
    int a = n - 1;
    while (a > i) {
      int p = dp[a] + c;
      if (arrey[i][a] == '1' && p % 2 == 0) {
        ans++;
        dp[a]++;
        c++;
        q[i]++;
        q[a]++;
      } else if (arrey[i][a] == '0' && p % 2 == 1) {
        ans++;
        dp[a]++;
        c++;
        q[i]++;
        q[a]++;
      }
      a--;
    }
  }
  fill(dp, dp + maxn, '0');
  for (int i = n - 1; i > 0; i--) {
    int a = 0;
    int c = 0;
    while (a < i) {
      int p = dp[a] + c;
      if (arrey[i][a] == '1' && p % 2 == 0) {
        ans++;
        dp[a]++;
        c++;
        q[i]++;
        q[a]++;
      } else if (arrey[i][a] == '0' && p % 2 == 1) {
        ans++;
        dp[a]++;
        c++;
        q[i]++;
        q[a]++;
      }
      a++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (arrey[i][i] == '1' && q[i] % 2 == 0) ans++;
    if (arrey[i][i] == '0' && q[i] % 2 == 1) ans++;
  }
  cout << ans << endl;
}
