#include <bits/stdc++.h>
using namespace std;
vector<int> gr[114514];
int dp[114514], pat[114514];
void dfs(int v, int u) {
  dp[v] = pat[v] = 0;
  for (int i = 0; i < gr[v].size(); i++) {
    int w = gr[v][i];
    if (u == w) continue;
    dfs(w, v);
    dp[v] += dp[w];
    if (pat[w] == 0) dp[v]++, pat[v] ^= 1;
  }
}
int main() {
  int n, m, a, b;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    gr[a].push_back(b);
    gr[b].push_back(a);
  }
  if (n % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }
  dfs(0, -1);
  cout << dp[0] << endl;
}
