#include <bits/stdc++.h>
using namespace std;
const int maxN = 100000 + 233;
int n, m;
vector<int> G[maxN];
int ans = 0;
int DFS(int u, int fa) {
  int cnt = 1;
  for (int v : G[u])
    if (v != fa) {
      int sz = DFS(v, u);
      cnt += sz;
      ans += (sz & 1);
    }
  return cnt;
}
int solve() {
  DFS(1, -1);
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  if (n & 1) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  if (n - 1 == m)
    printf("%d\n", solve());
  else
    printf("QAQ\n");
  return 0;
}
