#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  cin.sync_with_stdio(false);
  solve();
  return 0;
}
char s[4020][4020];
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    reverse(s[i], s[i] + n);
  }
  int revgor[4020], revvert[4020];
  int ans = 0;
  memset(revgor, 0, sizeof(revgor));
  memset(revvert, 0, sizeof(revvert));
  for (int sum = 0; sum < n - 1; ++sum) {
    for (int i = 0; i <= sum; ++i) {
      int j = sum - i;
      if ((s[i][j] + revgor[i] + revvert[j]) % 2) {
        ++ans;
        revgor[i] = !revgor[i];
        revvert[j] = !revvert[j];
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    s[i][n - 1 - i] += revvert[n - 1 - i] + revgor[i];
  }
  memset(revgor, 0, sizeof(revgor));
  memset(revvert, 0, sizeof(revvert));
  for (int sum = 2 * n - 2; sum > n - 1; --sum) {
    for (int i = 0; i <= sum; ++i) {
      int j = sum - i;
      if (j >= n) continue;
      if ((s[i][j] + revgor[i] + revvert[j]) % 2) {
        ++ans;
        revgor[i] = !revgor[i];
        revvert[j] = !revvert[j];
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    s[i][n - 1 - i] += revvert[n - 1 - i] + revgor[i];
  }
  for (int i = 0; i < n; ++i) {
    if (s[i][n - 1 - i] % 2) {
      ++ans;
    }
  }
  cout << ans;
}
