#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 2000 + 10;   bool mrk[MAX_N][MAX_N];   bool Ver[MAX_N][MAX_N];   bool Hor[MAX_N][MAX_N];   int N;   int Total;   void Solve(int x, int y) {     bool flag = false;     if ((mrk[x][y] ^ Ver[x][y] ^ Hor[x][y]) == 1) flag = true;     int dx = -1, dy = 1;     if (x < y) dx = 1, dy = -1;     if (x + dx != y + dx) Ver[x + dx][y] ^= (Ver[x][y] ^ flag);     if (y + dy != x + dy) Hor[x][y + dy] ^= (Hor[x][y] ^ flag);     mrk[x][y] ^= flag;     if (flag) Total++;   }   int main() {     ios::sync_with_stdio(false);     cin >> N;     for (int i = 0; i < N; i++)       for (int j = 0; j < N; j++) {         char temp;         cin >> temp;         mrk[j][i] = (temp -  0 );       }     for (int l = 0; l < N; l++)       for (int i = 0; i <= l; i++) {         Solve(N - 1 - i, l - i);         Solve(i, N - 1 - (l - i));       }     cout << Total << endl;     return 0;   }   