#include <bits/stdc++.h>
#pragma hdrstop
using namespace std;
void solve();
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
int n;
int c[3000][3000];
bool stolb[3000], str[3000];
int get_value(int i, int j) {
  return (c[i][j] + (int)str[i] + (int)stolb[j]) % 2;
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%1d", &c[i][j]);
  int ans = 0;
  for (int cur = 0; cur < n; cur++) {
    c[cur][cur] = get_value(cur, cur);
    str[cur] = 0;
    for (int i = n - 1; i > cur; i--) {
      if (get_value(cur, i)) {
        ans++;
        str[cur] = !str[cur];
        stolb[i] = !stolb[i];
      }
    }
    stolb[cur] = 0;
    for (int i = n - 1; i > cur; i--)
      if (get_value(i, cur)) {
        ans++;
        stolb[cur] = !stolb[cur];
        str[i] = !str[i];
      }
    if (get_value(cur, cur)) ans++;
  }
  cout << ans;
}
