#include <bits/stdc++.h>
using namespace std;
char mp[2002][2002];
int c[2002], r[2002];
int main() {
  ios::sync_with_stdio(0);
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> mp[i] + 1;
  for (int i = 1; i <= n; i++)
    for (int j = n; j > i; j--)
      if (c[i] ^ r[j] != mp[i][j] - '0') {
        ans++;
        c[i] ^= 1;
        r[j] ^= 1;
      }
  for (int i = 1; i <= n; i++)
    mp[i][i] = ((mp[i][i] - '0') ^ c[i] ^ r[i]) + '0';
  memset(c, 0, sizeof c);
  memset(r, 0, sizeof r);
  for (int i = n; i >= 1; i--)
    for (int j = 1; j <= i; j++)
      if (c[i] ^ r[j] != mp[i][j] - '0') {
        ans++;
        c[i] ^= 1;
        r[j] ^= 1;
      }
  cout << ans << endl;
}
