#include <bits/stdc++.h>
using namespace std;
int main() {
  bool s[2000][2000];
  bool upRow[2000], upColumn[2000], downRow[2000], downColumn[2000];
  memset((upRow), (0), sizeof(upRow)),
      memset((upColumn), (0), sizeof(upColumn)),
      memset((downRow), (0), sizeof(downRow)),
      memset((downColumn), (0), sizeof(downColumn));
  int N;
  cin >> N;
  for (int _n(N), i(0); i < _n; i++)
    for (int _n(N), j(0); j < _n; j++) {
      char c;
      cin >> c;
      s[i][j] = (c == '1');
    }
  int ans = 0;
  for (int i = N - 1; i > 0; --i)
    for (int j = 0; i + j < N; ++j) {
      int row = j;
      int column = i + j;
      if ((upRow[row] ^ upColumn[column]) != s[row][column]) {
        ++ans;
        upRow[row] = !upRow[row];
        upColumn[column] = !upColumn[column];
      }
      row = i + j;
      column = j;
      if ((downRow[row] ^ downColumn[column]) != s[row][column]) {
        ++ans;
        downRow[row] = !downRow[row];
        downColumn[column] = !downColumn[column];
      }
    }
  for (int _n(N), i(0); i < _n; i++)
    if ((upRow[i] ^ upColumn[i] ^ downRow[i] ^ downColumn[i]) != s[i][i]) ++ans;
  cout << ans << endl;
  return 0;
}
