#include <bits/stdc++.h>
using namespace std;
vector<string> v;
vector<int> fil, col;
void change(int a, int b) {
  if (v[a][b] == '1')
    v[a][b] = '0';
  else
    v[a][b] = '1';
}
void chf(int a) {
  if (fil[a])
    fil[a] = 0;
  else
    fil[a] = 1;
}
void chc(int a) {
  if (col[a])
    col[a] = 0;
  else
    col[a] = 1;
}
int main() {
  int n;
  cin >> n;
  v = vector<string>(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  int ans = 0;
  col = fil = vector<int>(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (col[j]) change(i, j);
      if (fil[j]) change(j, i);
    }
    int cb = 0;
    for (int j = i + 1; j < n - 1; j++) {
      if (v[i][j] != v[i][j + 1]) {
        chc(j);
        ans++;
        cb++;
      }
      if (v[j][i] != v[j + 1][i]) {
        chf(j);
        ans++;
        cb++;
      }
    }
    if (i < n - 1) {
      if (v[i][n - 1] == '1') {
        chc(n - 1);
        ans++;
        cb++;
      }
      if (v[n - 1][i] == '1') {
        chf(n - 1);
        ans++;
        cb++;
      }
    }
    if (cb % 2 != (v[i][i] - '0')) ans++;
  }
  cout << ans << endl;
}
