#include <bits/stdc++.h>
using namespace std;
int c[100005], C[100005], g[100005];
int S;
vector<int> r[100005];
int f(int x) {
  int i;
  c[x]++;
  for (i = 0; i < r[x].size(); i++) {
    if (c[r[x][i]]) continue;
    g[r[x][i]] = x;
    f(r[x][i]);
  }
  if (x == 1 && C[x] == 0)
    S = -1;
  else if (C[x] == 0)
    C[x] = 1, C[g[x]] = 1 - C[g[x]], S++;
}
int main() {
  int n, m, s, e, i;
  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d %d", &s, &e);
    r[s].push_back(e);
    r[e].push_back(s);
  }
  f(1);
  printf("%d\n", S);
  return 0;
}
