#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5, lg = 20;
int main() {
  int n, ans = 0;
  cin >> n;
  vector<bool> grid[n];
  bool rast[n];
  bool chap[n];
  fill(rast, rast + n, 0);
  fill(chap, chap + n, 0);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (auto c : s) grid[i].push_back(c - '0');
  }
  for (int i = n - 1; i > -1; i--) {
    bool c = 0;
    for (int j = 0; j < i; j++) {
      if (grid[j][i] ^ c ^ rast[j]) {
        grid[j][j] = grid[j][j] ^ 1;
        rast[j] ^= 1;
        c ^= 1;
        ans++;
      }
    }
    bool c2 = 0;
    for (int j = 0; j < i; j++) {
      if (grid[i][j] ^ c2 ^ chap[j]) {
        grid[j][j] = grid[j][j] ^ 1;
        chap[j] ^= 1;
        c2 ^= 1;
        ans++;
      }
    }
    if (grid[i][i] ^ c ^ c2) ans++;
  }
  cout << ans;
}
