#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool grid[2020][2020];
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < n; ++j) grid[i][j] = s[j] - '0';
  }
  vector<pair<int, int> > points;
  bool flips[2020];
  memset(flips, 1, sizeof(flips));
  for (int i = 0; i < n; ++i) {
    bool flip = true;
    for (int j = n - 1; j > i; --j) {
      if (grid[i][j] != flip ^ flips[j]) {
        flip = !flip;
        flips[j] = !flips[j];
        grid[i][i] = !grid[i][i];
        grid[j][j] = !grid[j][j];
        points.push_back(make_pair(i, j));
      }
    }
  }
  memset(flips, 1, sizeof(flips));
  for (int j = 0; j < n; ++j) {
    bool flip = true;
    for (int i = n - 1; i > j; --i) {
      if (grid[i][j] != flip ^ flips[i]) {
        flip = !flip;
        grid[j][j] = !grid[j][j];
        grid[i][i] = !grid[i][i];
        flips[i] = !flips[i];
        points.push_back(make_pair(i, j));
      }
    }
  }
  for (int i = 0; i < n; ++i)
    if (grid[i][i]) points.push_back(make_pair(i, i));
  cout << points.size() << endl;
}
