#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int MAXN = 1 << 17;
const int MOD = 1;
const int INF = 2e9;
const double PI = acos(-1.0);
vector<int> e[MAXN];
int dfs(int v, int pr) {
  int sum = 0;
  for (int to : e[v]) {
    if (to == pr) continue;
    int res = dfs(to, v);
    if (res == -1) return -1;
    sum += res;
  }
  if (sum == 0) return 1;
  if (sum == 1) return 0;
  return -1;
}
int main() {
  int n, m;
  while (cin >> m >> n) {
    for (int i = 0; i < n; i++) e[i].clear();
    for (int i = 0; i < m; i++) {
      int u, v;
      cin >> u >> v;
      --u;
      --v;
      e[u].push_back(v);
      e[v].push_back(u);
    }
    int ans;
    for (int i = 0; i < n; i++) {
      if (e[i].size() == 1) {
        ans = dfs(i, -1);
        break;
      }
    }
    cout << (ans == 0 ? n / 2 : 0) << endl;
  }
  return 0;
}
