#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
A convert(B x) {
  stringstream s;
  s << x;
  A r;
  s >> r;
  return r;
}
int a[2002][2002], n;
char ch[2002];
int SR[2002], SC[2002];
int sr[2002], sc[2002];
int Calc() {
  for (int i = (0), _b(n); i < _b; ++i) sr[i] = sc[i] = 0;
  int res = 0;
  for (int j = (n)-1, _a(1); j >= _a; --j) {
    for (int i = (0), _b(n - j); i < _b; ++i) {
      int val = (a[i][j + i] + sr[i] + sc[j + i]) % 2;
      if (!val) continue;
      sr[i]++;
      sc[i + j]++;
      res++;
    }
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = (0), _b(n); i < _b; ++i) {
    scanf("%s", ch);
    for (int j = (0), _b(n); j < _b; ++j) a[i][j] = (ch[j] - '0');
  }
  memset(SR, 0, sizeof(SR));
  memset(SC, 0, sizeof(SC));
  int res = 0;
  res += Calc();
  for (int i = (0), _b(n); i < _b; ++i)
    for (int j = (i), _b(n); j < _b; ++j) swap(a[i][j], a[j][i]);
  for (int i = (0), _b(n); i < _b; ++i) {
    SR[i] += sr[i];
    SC[i] += sc[i];
  }
  res += Calc();
  for (int i = (0), _b(n); i < _b; ++i)
    for (int j = (i), _b(n); j < _b; ++j) swap(a[i][j], a[j][i]);
  for (int i = (0), _b(n); i < _b; ++i) {
    SR[i] += sc[i];
    SC[i] += sr[i];
  }
  for (int i = (0), _b(n); i < _b; ++i) res += (a[i][i] + SR[i] + SC[i]) % 2;
  cout << res << endl;
  return 0;
}
