#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> gph[100005];
int sz[100005];
int dfs(int x, int p) {
  sz[x] = 1;
  for (auto &i : gph[x]) {
    if (i == p) continue;
    dfs(i, x);
    sz[x] += sz[i];
  }
  return 0;
}
int main() {
  cin >> n >> m;
  if (n % 2 == 1) {
    puts("-1");
    return 0;
  }
  assert(m == n - 1);
  for (int i = 0; i < n - 1; i++) {
    int s, e;
    scanf("%d %d", &s, &e);
    gph[s].push_back(e);
    gph[e].push_back(s);
  }
  dfs(1, 0);
  int ret = 0;
  for (int i = 2; i <= n; i++) {
    if (sz[i] % 2 == 1) ret++;
  }
  cout << ret << endl;
}
