#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "sz = " << vc.size() << endl << "[";
  for (const T& v : vc) o << v << ",";
  o << "]";
  return o;
}
int N, M;
const int MX = 100000;
vector<int> G[MX];
long long ans;
int dfs(int v, int p, bool d) {
  int t = 1;
  for (int u : G[v])
    if (u != p) {
      t -= dfs(u, v, !d);
    }
  ans += abs(t);
  return t;
}
int main() {
  cin >> N >> M;
  if (M != N - 1) {
    puts("Impossible");
    return 0;
  }
  for (int i = 0; i < (int)(N - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  if (dfs(0, -1, 0) != 0) {
    puts("-1");
    return 0;
  }
  cout << ans << endl;
}
