#include <bits/stdc++.h>
using namespace std;
const int MN = 5000;
int n, ans = 0;
bool grid[MN][MN], row1[MN], row2[MN], col1[MN], col2[MN];
int main() {
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (s[i][j] == '1') grid[i][j] = 1;
  for (int i = n - 1; i > 0; i--)
    for (int j = 0; j < i; j++)
      if (row1[i] ^ col1[j] != grid[i][j]) {
        row1[i] ^= 1;
        col1[j] ^= 1;
        ans++;
      }
  for (int i = 0; i < n - 1; i++)
    for (int j = n - 1; j > i; j--)
      if (row2[i] ^ col2[j] != grid[i][j]) {
        row2[i] ^= 1;
        col2[j] ^= 1;
        ans++;
      }
  for (int i = 0; i < n; i++)
    if (row1[i] ^ row2[i] ^ col1[i] ^ col2[i] != grid[i][i]) ans++;
  cout << ans;
  return 0;
}
