#include <bits/stdc++.h>
using namespace std;
const int MAX = 2005;
bool a[MAX][MAX], row[MAX], col[MAX];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      a[i][j] = (c == '1');
    }
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = n - 1; j > i; j--)
      if (a[i][j] ^ row[i] ^ col[j]) {
        a[i][j] = false;
        row[i] = !row[i];
        col[j] = !col[j];
        ans++;
      }
  for (int i = 0; i < n; i++) {
    a[i][i] ^= row[i] ^ col[i];
    row[i] = col[i] = false;
  }
  for (int j = 0; j < n; j++)
    for (int i = n - 1; i > j; i--)
      if (a[i][j] ^ row[i] ^ col[j]) {
        a[i][j] = false;
        row[i] = !row[i];
        col[j] = !col[j];
        ans++;
      }
  for (int i = 0; i < n; i++) ans += (a[i][i] ^ row[i] ^ col[i]);
  cout << ans;
  return 0;
}
