#include <bits/stdc++.h>
using namespace std;
int n, res = 0;
vector<vector<bool>> vis;
vector<vector<int>> b;
vector<vector<pair<int, int>>> push;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  b.assign(n, vector<int>(n, 0));
  push.assign(n, vector<pair<int, int>>(n, {0, 0}));
  vis.assign(n, vector<bool>(n, 0));
  for (int i = 0; i < n; ++i) {
    string second;
    cin >> second;
    for (int j = 0; j < n; ++j) {
      b[i][j] = second[j] - '0';
    }
  }
  queue<pair<int, int>> q;
  q.push({0, n - 1});
  q.push({n - 1, 0});
  vis[0][n - 1] = true;
  vis[n - 1][0] = true;
  int dxx[] = {0, -1};
  int dyx[] = {1, 0};
  int dxy[] = {0, 1};
  int dyy[] = {-1, 0};
  while (!q.empty()) {
    pair<int, int> cur = q.front();
    q.pop();
    if (cur.first == cur.second) continue;
    int tp = 0;
    if ((b[cur.first][cur.second] + push[cur.first][cur.second].first +
         push[cur.first][cur.second].second) %
        2) {
      tp++, res++;
      push[cur.first][cur.second].first++;
      push[cur.first][cur.second].second++;
    }
    int dx[2], dy[2];
    if (cur.first > cur.second) {
      dx[0] = dxx[0];
      dx[1] = dxx[1];
      dy[0] = dyx[0];
      dy[1] = dyx[1];
    } else {
      dx[0] = dxy[0];
      dx[1] = dxy[1];
      dy[0] = dyy[0];
      dy[1] = dyy[1];
    }
    for (int i = 0; i < 2; ++i) {
      if (cur.first + dx[i] >= 0 && cur.first + dx[i] < n &&
          cur.second + dy[i] >= 0 && cur.second + dy[i] < n) {
        if (dx[i] == 0) {
          push[cur.first][cur.second + dy[i]].second +=
              push[cur.first][cur.second].second;
        }
        if (dy[i] == 0) {
          push[cur.first + dx[i]][cur.second].first +=
              push[cur.first][cur.second].first;
        }
        if (!vis[cur.first + dx[i]][cur.second + dy[i]]) {
          vis[cur.first + dx[i]][cur.second + dy[i]] = true;
          q.push({cur.first + dx[i], cur.second + dy[i]});
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if ((push[i][i].first + push[i][i].second + b[i][i]) % 2) {
      res++;
    }
  }
  cout << res;
  return 0;
}
