#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
char img[2007][2007];
int c[2007], r[2007];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%s", img[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) img[i][j] -= '0';
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = n - 1; j > i; --j)
      if (c[j] ^ r[i] ^ img[i][j]) {
        ++ans;
        c[j] ^= 1, r[i] ^= 1;
      }
  for (int i = 0; i < n; i++) img[i][i] ^= c[i] ^ r[i];
  memset(c, 0, sizeof(c)), memset(r, 0, sizeof(r));
  for (int i = n - 1; i >= 0; --i)
    for (int j = 0; j < i + 1; j++)
      if (c[j] ^ r[i] ^ img[i][j]) {
        ++ans;
        c[j] ^= 1, r[i] ^= 1;
      }
  cout << ans << endl;
  return 0;
}
