#include <bits/stdc++.h>
using namespace std;
vector<int> edge[100005];
int deg[100005], n, m;
queue<int> que;
int col[100005], used[100005], cnt[100005], ans;
void dfs(int v, int u) {
  for (int i = 0; i < edge[v].size(); i++) {
    if (edge[v][i] == u) continue;
    dfs(edge[v][i], v);
    cnt[v] += cnt[edge[v][i]];
  }
  cnt[v]++;
  ans += (cnt[v] % 2);
}
int main() {
  scanf("%d%d", &n, &m);
  assert(n == m + 1);
  if (n % 2 == 1) {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  dfs(1, -1);
  cout << ans << endl;
}
