#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  vector<int> stolb1(n, 0), stolb2(n, 0), diag(n, 0);
  int count = 0;
  for (int i = 0; i < n - 1; ++i) {
    int c = 0;
    for (int j = n - 1; j > i; --j) {
      if (s[i][j] - '0' != (c + stolb1[j]) % 2) {
        c = 1 - c;
        ++count;
        stolb1[j] = 1 - stolb1[j];
      }
    }
    diag[i] = c;
  }
  for (int i = n - 1; i > 0; --i) {
    int c = 0;
    for (int j = 0; j < i; ++j) {
      if (s[i][j] - '0' != (c + stolb2[j]) % 2) {
        c = 1 - c;
        ++count;
        stolb2[j] = 1 - stolb2[j];
      }
    }
    diag[i] += c;
    diag[i] %= 2;
  }
  for (int i = 0; i < n; ++i) {
    if (s[i][i] - '0' != (diag[i] + stolb1[i] + stolb2[i]) % 2) {
      ++count;
    }
  }
  cout << count;
  return 0;
}
