#include <bits/stdc++.h>
using namespace std;
const int maxN = 2010;
char s[maxN][maxN];
char row[maxN];
char col[maxN];
int n;
int ans;
void solve() {
  for (int k = n - 1; k >= (1); k--)
    for (int i = 0; i < (n - k); i++) {
      int j = k + i;
      if (s[i][j] ^ row[i] ^ col[j]) {
        ans++;
        row[i] ^= 1;
        col[j] ^= 1;
        s[i][i] ^= 1;
        s[j][j] ^= 1;
      }
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> s[i];
    for (int j = 0; j < (n); j++) s[i][j] -= '0';
  }
  solve();
  for (int i = 0; i < (n); i++) {
    fill(row, row + n, char(0));
    fill(col, col + n, char(0));
    for (int j = i + 1; j < (n); j++) s[i][j] = s[j][i];
  }
  solve();
  for (int i = 0; i < (n); i++)
    if (s[i][i]) ans++;
  cout << ans << endl;
  return 0;
}
