#include <bits/stdc++.h>
using namespace std;
inline int gi() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - 48;
    ch = getchar();
  }
  return x * f;
}
template <typename T>
inline bool Max(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline bool Min(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
const int N = 1e5 + 7;
int n, m, edc, a, b;
int head[N], du[N], g[N];
struct edge {
  int lst, to;
  edge() {}
  edge(int lst, int to) : lst(lst), to(to) {}
} e[N << 1];
void Add(int a, int b) {
  ++du[a], ++du[b];
  e[++edc] = edge(head[a], b), head[a] = edc;
  e[++edc] = edge(head[b], a), head[b] = edc;
}
void dfs(int u, int fa) {
  int cnt1 = 0, cnt2 = 0;
  for (int i = head[u], v = e[i].to; i; i = e[i].lst, v = e[i].to)
    if (v ^ fa) {
      dfs(v, u);
      if (du[v] == 1)
        ++cnt1;
      else
        cnt2 += g[v];
    }
  g[u] = max(cnt1, cnt2) - min(cnt1, cnt2);
  b += g[u];
}
int main() {
  n = gi(), m = gi();
  if (n & 1) return puts("-1"), 0;
  for (int i = 1; i <= m; ++i) Add(gi(), gi());
  for (int i = 1; i <= n; ++i)
    if (du[i] == 1) ++a;
  dfs(1, 0);
  printf("%d\n", a + b / 2);
  return 0;
}
