#include <bits/stdc++.h>
using namespace std;
bool mapa[2050][2050];
bool mapa2[2050][2050];
int arr[2050][2050];
int arr2[2050][2050];
int arrd[2050];
int main() {
  int N, total = 0;
  memset(mapa, false, sizeof mapa);
  memset(mapa2, false, sizeof mapa2);
  memset(arr, 0, sizeof arr);
  memset(arr2, 0, sizeof arr2);
  memset(arrd, 0, sizeof arrd);
  string s;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> s;
    for (int j = 0; j < N; ++j) {
      if (s[j] == '0') mapa[i][j] = false;
      if (s[j] == '1') mapa[i][j] = true;
    }
  }
  for (int i = 0; i < N - 1; ++i) {
    for (int j = N - 1; j > i; j--) {
      if ((arr[i][j] + arr2[i][j]) % 2 == 0) {
        if (mapa[i][j] != mapa2[i][j]) {
          total++;
          arr[i][j - 1] += arr[i][j] + 1;
          arr2[i + 1][j] += arr2[i][j] + 1;
        } else {
          arr[i][j - 1] += arr[i][j];
          arr2[i + 1][j] += arr2[i][j];
        }
      } else {
        if (mapa[i][j] == mapa2[i][j]) {
          total++;
          arr[i][j - 1] += arr[i][j] + 1;
          arr2[i + 1][j] += arr2[i][j] + 1;
        } else {
          arr[i][j - 1] += arr[i][j];
          arr2[i + 1][j] += arr2[i][j];
        }
      }
    }
  }
  for (int i = N - 1; i > 0; i--) {
    for (int j = 0; j < i; j++) {
      if ((arr[i][j] + arr2[i][j]) % 2 == 0) {
        if (mapa[i][j] != mapa2[i][j]) {
          total++;
          arr[i][j + 1] += arr[i][j] + 1;
          arr2[i - 1][j] += arr2[i][j] + 1;
        } else {
          arr[i][j + 1] += arr[i][j];
          arr2[i - 1][j] += arr2[i][j];
        }
      } else {
        if (mapa[i][j] == mapa2[i][j]) {
          total++;
          arr[i][j + 1] += arr[i][j] + 1;
          arr2[i - 1][j] += arr2[i][j] + 1;
        } else {
          arr[i][j + 1] += arr[i][j];
          arr2[i - 1][j] += arr2[i][j];
        }
      }
    }
  }
  for (int i = 0; i < N; ++i) {
    if ((arr[i][i] + arr2[i][i]) % 2 == 0) {
      if (mapa[i][i] != mapa2[i][i]) {
        total++;
      }
    } else {
      if (mapa[i][i] == mapa2[i][i]) {
        total++;
      }
    }
  }
  cout << total << endl;
  return 0;
}
