#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2010;
int n;
long long ans;
char a[MAX_N][MAX_N], b[MAX_N][MAX_N];
short up[MAX_N][MAX_N];
short rgh[MAX_N][MAX_N];
vector<int> solve(char c[MAX_N][MAX_N]) {
  memset(up, 0, sizeof(up));
  memset(rgh, 0, sizeof(rgh));
  vector<int> ret(n);
  for (int i = 0; i < n; i++)
    for (int j = n - 1; j >= i; j--) {
      up[i][j] = i - 1 >= 0 ? up[i - 1][j] : 0;
      rgh[i][j] = j + 1 < n ? rgh[i][j + 1] : 0;
      if (((up[i][j] ^ rgh[i][j]) & 1) != c[i][j] - '0') {
        if (i != j) {
          ans++;
          up[i][j]++;
          rgh[i][j]++;
        } else
          ret[i] = 1;
      } else {
        if (i == j) ret[i] = 0;
      }
    }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", a[i]);
    for (int j = 0; j < n; j++) b[n - 1 - i][n - 1 - j] = a[i][j];
  }
  vector<int> x = solve(a), y = solve(b);
  reverse(y.begin(), y.end());
  for (int i = 0; i < n; i++)
    if (((x[i] ^ y[i]) & 1) != a[i][i] - '0') ans++;
  cout << ans << '\n';
  return 0;
}
