#include <bits/stdc++.h>
using namespace std;
const int maxN = 5e3 + 100;
int ngang[maxN], doc[maxN];
char s[maxN][maxN];
int n;
void init() {
  memset(ngang, 0, sizeof(ngang));
  memset(doc, 0, sizeof(doc));
}
int main() {
  scanf("%i\n", &n);
  for (int i = 0; i < n; i++) scanf("%s\n", s[i]);
  init();
  int res = 0;
  for (int i = 0; i < n; i++)
    for (int j = n - 1; j > i; j--) {
      int t = s[i][j] - '0' + ngang[i] + doc[j];
      if (t % 2 == 1) ++res, ++ngang[i], ++doc[j];
    }
  for (int i = 0; i < n; i++)
    s[i][i] = (s[i][i] - '0' + ngang[i] + doc[i]) % 2 + '0';
  init();
  for (int i = n - 1; i > 0; i--)
    for (int j = 0; j < i; j++) {
      int t = s[i][j] - '0' + ngang[i] + doc[j];
      if (t % 2 == 1) ++res, ++ngang[i], ++doc[j];
    }
  for (int i = 0; i < n; i++)
    s[i][i] = (s[i][i] - '0' + ngang[i] + doc[i]) % 2 + '0';
  for (int i = 0; i < n; i++)
    if (s[i][i] == '1') ++res;
  cout << res;
}
