#include <bits/stdc++.h>
using namespace std;
int N, M, A[101010], B[101010];
vector<int> graph[101010];
int flg[101010];
long long ans = 0;
int solve(int p, int rt) {
  int w = -1;
  for (int q : graph[p])
    if (q != rt) {
      int tmp = solve(q, p);
      w += tmp;
    }
  ans += abs(w);
  return -w;
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; ++i) {
    scanf("%d%d", A + i, B + i);
    --A[i];
    --B[i];
    graph[A[i]].push_back(B[i]);
    graph[B[i]].push_back(A[i]);
  }
  if (M != N - 1) {
    puts("(>_<)");
    return 0;
  }
  ans = 0;
  if (solve(0, -1) != 0) ans = -1;
  printf("%lld\n", ans);
  return 0;
}
