#include <bits/stdc++.h>
using namespace std;
const int MAX = 2000;
int r[2][MAX + 10];
int c[2][MAX + 10];
bool b[MAX + 10][MAX + 10];
char ch[MAX + 10][MAX + 10];
int n;
int cnt;
void com(int i, int j) {
  cnt++;
  if (i == j) return;
  r[(j > i ? 0 : 1)][i]++;
  c[(j > i ? 0 : 1)][j]++;
}
bool a(int i, int j) {
  if (i == j) return ((r[0][i] + r[1][i] + c[0][i] + c[1][i]) & 1);
  if (j > i) return ((r[0][i] + c[0][j]) & 1);
  return ((r[1][i] + c[1][j]) & 1);
}
void solve() {
  for (int i = 0; i < n; i++)
    for (int j = n - 1; j > i; j--)
      if (a(i, j) != b[i][j]) com(i, j);
  for (int i = n - 1; i >= 0; i--)
    for (int j = 0; j < i; j++)
      if (a(i, j) != b[i][j]) com(i, j);
  for (int i = 0; i < n; i++)
    if (a(i, i) != b[i][i]) com(i, i);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> ch[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) b[i][j] = ch[i][j] - '0';
  solve();
  cout << cnt << endl;
  return 0;
}
