#include <bits/stdc++.h>
int n;
char g[2000][2001];
void solve() {
  int ans = 0;
  bool tag_col[n], tag_row[n], tag1, tag2;
  memset(tag_col, false, sizeof(tag_col));
  memset(tag_row, false, sizeof(tag_row));
  for (int i = 0; i < n; ++i) {
    tag1 = false;
    for (int j = n - 1; j > i; --j) {
      bool tmp = tag_col[j] ^ tag1;
      if (g[i][j] == '1' && tmp == false || g[i][j] == '0' && tmp == true) {
        ++ans;
        g[i][j] = '0';
        tag1 = !tag1;
        tag_col[j] = !tag_col[j];
      }
    }
    tag2 = false;
    for (int j = n - 1; j > i; --j) {
      bool tmp = tag_row[j] ^ tag2;
      if (g[j][i] == '1' && tmp == false || g[j][i] == '0' && tmp == true) {
        ++ans;
        g[j][i] = '0';
        tag2 = !tag2;
        tag_row[j] = !tag_row[j];
      }
    }
    bool tmp = tag1 ^ tag2 ^ tag_col[i] ^ tag_row[i];
    if (g[i][i] == '1' && tmp == false || g[i][i] == '0' && tmp == true) {
      ++ans;
      g[i][i] = '0';
    }
  }
  printf("%d\n", ans);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", g[i]);
  }
  solve();
  return 0;
}
