#include <bits/stdc++.h>
using namespace std;
int ok(vector<pair<int, int> >& a) {
  int x = 0, y = 0;
  for (auto i : a) {
    x += i.first;
    y += i.second;
  }
  return x % 2 == 0 && y % 2 == 0;
}
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  vector<pair<int, int> > cpy = a;
  int ans = INT_MAX;
  for (int i = 0; i < n; i++) {
    int preans = 0;
    for (int j = i; j < n; j++) {
      if (ok(a)) {
        ans = min(ans, preans);
      }
      swap(a[j].first, a[j].second);
      preans++;
    }
    a = cpy;
  }
  if (ans == INT_MAX)
    cout << -1;
  else
    cout << ans;
  return 0;
}
