#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T a) {
  return a * a;
}
char s[2100][2100];
int h[2100];
int v[2100];
int h2[2100];
int v2[2100];
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  int res = 0;
  for (int k = n - 1; k >= 1; k--)
    for (int i = k, j = 0; i < n; i++, j++) {
      int u = s[i][j] == '1';
      int w = (h[i] + v[j]) % 2;
      if (u != w) {
        res++;
        h[i] = !h[i];
        v[j] = !v[j];
      }
    }
  for (int k = n - 1; k >= 1; k--)
    for (int i = 0, j = k; j < n; i++, j++) {
      int u = s[i][j] == '1';
      int w = (h2[i] + v2[j]) % 2;
      if (u != w) {
        res++;
        h2[i] = !h2[i];
        v2[j] = !v2[j];
      }
    }
  for (int k = 0; k < n; k++) {
    int u = s[k][k] == '1';
    int w = (h[k] + v[k] + h2[k] + v2[k]) % 2;
    if (u != w) res++;
  }
  cout << res;
  return 0;
}
