#include <bits/stdc++.h>
int main() {
  int n, i, j, count = 0, f = 1, temp;
  scanf("%d", &n);
  int a[n][2];
  for (i = 0; i < n; i++) {
    for (j = 0; j < 2; j++) scanf("%d", &a[i][j]);
  }
  int sum1 = 0, sum2 = 0;
  for (i = 0; i < n; i++) {
    sum1 = sum1 + a[i][0];
  }
  for (i = 0; i < n; i++) {
    sum2 = sum2 + a[i][1];
  }
  if (sum2 % 2 == 0 && sum1 % 2 == 0)
    printf("0");
  else {
    for (i = 0; i < n; i++) {
      if ((a[i][0] + a[i][1]) % 2 != 0 && f % 2 != 0) {
        count++;
        temp = a[i][0];
        a[i][0] = a[i][1];
        a[i][1] = temp;
        f++;
      }
    }
    sum1 = 0;
    sum2 = 0;
    for (i = 0; i < n; i++) sum1 = sum1 + a[i][0];
    for (i = 0; i < n; i++) {
      sum2 = sum2 + a[i][1];
    }
    if (sum2 % 2 == 0 && sum1 % 2 == 0)
      printf("%d", count);
    else
      printf("-1");
  }
}
