#include <bits/stdc++.h>
using namespace std;
vector<int> edge[100005];
int n, m;
int col[100005], ans;
void dfs(int v, int u) {
  for (int i = 0; i < edge[v].size(); i++) {
    if (edge[v][i] == u) continue;
    dfs(edge[v][i], v);
    if (!col[edge[v][i]]) {
      col[edge[v][i]] ^= 1;
      col[v] ^= 1;
      ans++;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  assert(n == m + 1);
  if (n % 2 == 1) {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  int ret = 1000000;
  srand((unsigned)time(NULL));
  for (int i = 0; i < 30; i++) {
    memset(col, 0, sizeof(col));
    ans = 0;
    dfs(rand() % n + 1, -1);
    ret = min(ret, ans);
  }
  cout << ret << endl;
}
