#include <bits/stdc++.h>
using namespace std;
int n;
vector<string> s;
vector<int> hor, ver;
vector<int> diag;
int findAns() {
  hor.assign(n + 1, 0);
  ver.assign(n + 1, 0);
  int ans = 0;
  for (int i = 0; i + 1 < n; i++)
    for (int j = n - 1; j > i; j--) {
      int rev = hor[i] ^ ver[j];
      if (rev != (s[i][j] - '0')) {
        ans++;
        hor[i] ^= 1;
        ver[j] ^= 1;
      }
    }
  for (int i = 0; i < n; i++) diag[i] ^= hor[i] ^ ver[i];
  return ans;
}
int main() {
  cin >> n;
  s.resize(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  diag.assign(n, 0);
  int ans = findAns();
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      char c = s[i][j];
      s[i][j] = s[j][i];
      s[j][i] = c;
    }
  ans += findAns();
  for (int i = 0; i < n; i++)
    if (s[i][i] - '0' != diag[i]) ans++;
  cout << ans << "\n";
  return 0;
}
