#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename... t>
using V = vector<t...>;
template <typename t>
void print(ostream& os, const t& a) {
  os << a << '\n';
}
template <typename t, typename... v>
void print(ostream& os, const t& a, v&&... b) {
  os << a << ' ';
  print(os, b...);
}
constexpr int maxn = 2e3;
enum wh { u, d, l, r };
int n, res;
bool tb[maxn + 1][maxn + 1];
bool ilo[maxn + 2][maxn + 2][4];
pair<int, int> M[4] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
inline void alg(int i, int k, V<int> d) {
  bool st = false;
  for (int s : d) {
    auto& p = M[s];
    int ni = i + p.first;
    int nk = k + p.second;
    st = st xor ilo[ni][nk][s];
  }
  if (st != tb[i][k])
    ++res, st = 1;
  else
    st = 0;
  for (int s : d) {
    auto& p = M[s];
    int ni = i + p.first;
    int nk = k + p.second;
    ilo[i][k][s] = ilo[ni][nk][s] xor st;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  ;
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    for (int k = 1; k <= n; ++k) tb[i][k] = (s[k - 1] - '0');
  }
  for (int i = 1; i <= n; ++i) {
    for (int k = n - i + 1; k >= i + 1; --k) alg(i, k, {wh::u, wh::r});
    for (int k = i + 1; k < n - i + 1; ++k) alg(k, n - i + 1, {wh::u, wh::r});
  }
  for (int i = n; i >= 1; --i) {
    for (int k = 1; k < i; ++k) alg(i, k, {wh::d, wh::l});
    for (int k = i - 1; k > i; --k) alg(k, n - i + 1, {wh::d, wh::l});
  }
  for (int i = 1; i <= n; ++i) alg(i, i, {wh::u, wh::d, wh::l, wh::r});
  print(cout, res);
}
