#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, sum1 = 0, sum2 = 0;
  cin >> n;
  int x[n], y[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    sum1 += x[i];
    sum2 += y[i];
  }
  if (sum1 % 2 == 0 && sum2 % 2 == 0) {
    cout << 0 << endl;
  } else {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (x[i] % 2 != y[i] % 2) {
        sum1 -= x[i];
        sum1 += y[i];
        sum2 -= y[i];
        sum2 += x[i];
        cnt++;
      }
      if (sum1 % 2 == 0 && sum2 % 2 == 0) {
        cout << cnt << endl;
        return 0;
      }
    }
    cout << "-1" << endl;
    return 0;
  }
}
