#include <bits/stdc++.h>
using namespace std;
int OO = 1e5, n;
pair<int, int> dom[100];
int memo[100][601][601];
int dp(int i, int sum1, int sum2) {
  if (i == n) return (sum1 % 2 || sum2 % 2) * OO;
  int &ret = memo[i][sum1][sum2];
  if (ret != -1) return ret;
  return ret = min(dp(i + 1, sum1 + dom[i].first, sum2 + dom[i].second),
                   1 + dp(i + 1, sum1 + dom[i].second, sum2 + dom[i].first));
}
int main() {
  memset(memo, -1, sizeof memo);
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d%d", &dom[i].first, &dom[i].second);
  int ans = dp(0, 0, 0);
  ans >= OO ? printf("-1") : printf("%d", ans);
  return 0;
}
