#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline void chmin(A &a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b) {
  if (a < b) a = b;
}
long long N, M;
vector<long long> G[111111];
long long col[111111];
long long dfs(long long v, long long p) {
  long long ret = 0;
  for (auto u : G[v]) {
    if (u == p) continue;
    ret += dfs(u, v);
  }
  if (col[v] == 0) {
    if (v == 0) return -1;
    ret++;
    col[p] = 1 - col[p];
  }
  return ret;
}
signed main() {
  cin >> N >> M;
  for (long long i = 0; i < (M); i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  if (N == M) return 0;
  cout << dfs(0, -1) << endl;
}
