#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int up, dn;
  int a = 0, b = 0, c = 0;
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &up, &dn);
    if (up % 2 == 0 && dn % 2 == 0) continue;
    if (up % 2 != 0 && dn % 2 == 0)
      a++;
    else if (up % 2 == 0 && dn % 2 != 0)
      b++;
    else
      c++;
  }
  int minn = 20000;
  for (i = 0; i <= a; i++)
    for (j = 0; j <= b; j++) {
      if ((c + a - i + j) % 2 == 0 && (c + b - j + i) % 2 == 0) {
        if (minn > j + i) {
          minn = j + i;
        }
      }
    }
  if (minn == 20000)
    printf("-1\n");
  else
    printf("%d\n", minn);
  return 0;
}
