#include <bits/stdc++.h>
using namespace std;
int n, m = 0, x, y, k1 = 0, k2 = 0, s1 = 0, s2 = 0;
vector<pair<int, int> > v;
bool t = false;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    v.push_back(make_pair(x, y));
    if (x % 2 == 1) k1++;
    if (y % 2 == 1) k2++;
  }
  if (k1 % 2 == 1 && k2 % 2 == 1) {
    for (int i = 0; i < n; i++) {
      if (v[i].first % 2 == 1 && v[i].second % 2 == 0) {
        m++;
        t = true;
        break;
      } else if (v[i].first % 2 == 0 && v[i].second % 2 == 1) {
        m++;
        t = true;
        break;
      }
    }
  } else if (k1 % 2 == 1 && k2 % 2 == 0) {
    cout << -1;
    return 0;
  } else if (k1 % 2 == 0 && k2 % 2 == 1) {
    cout << -1;
    return 0;
  } else {
    cout << 0;
    return 0;
  }
  if (t)
    cout << m;
  else
    cout << -1;
  return 0;
}
