#include <bits/stdc++.h>
const int maxn = 2e5 + 222;
int n, m, idx, ind, ans, dfn[maxn], low[maxn], vis[maxn], dgr[maxn], u[maxn],
    v[maxn], f[maxn], h[maxn], in[maxn];
std::vector<int> ch[maxn], E[maxn];
std::set<std::pair<int, int> > S;
std::stack<int> stk;
void tarjan(int u, int fa) {
  stk.push(u);
  dfn[u] = low[u] = ++idx;
  for (int v : E[u]) {
    if (v == fa) continue;
    if (!dfn[v]) {
      tarjan(v, u);
      low[u] = std::min(low[u], low[v]);
    } else
      low[u] = std::min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    ++ind;
    while (1) {
      int x = stk.top();
      stk.pop();
      in[x] = ind;
      if (x == u) break;
      ans++;
    }
  }
}
void dfs(int u, int fa) {
  h[u] = 1;
  vis[u] = f[u] = 1;
  std::vector<int> vec = {0, 0};
  for (int v : ch[u]) {
    if (v == fa || dgr[v] <= 1) continue;
    dfs(v, u);
    f[u] = std::max(f[u], f[v]);
    h[u] = std::max(h[u], h[v] + 1);
    vec.push_back(h[v]);
  }
  std::sort(vec.begin(), vec.end(), [](int a, int b) { return a > b; });
  f[u] = std::max(f[u], vec[0] + vec[1] + 1);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &u[i], &v[i]);
    E[u[i]].push_back(v[i]);
    E[v[i]].push_back(u[i]);
  }
  ans = -1;
  for (int i = 1; i <= n; ++i) {
    if (!dfn[i]) {
      ans++;
      tarjan(i, 0);
    }
  }
  for (int i = 1; i <= m; ++i) {
    int x = in[u[i]], y = in[v[i]];
    if (x == y) continue;
    if (x > y) std::swap(x, y);
    if (S.find({x, y}) != S.end()) continue;
    S.insert({x, y});
    ch[x].push_back(y);
    ch[y].push_back(x);
    dgr[x]++;
    dgr[y]++;
  }
  for (int i = 1; i <= ind; ++i) ans += (dgr[i] > 1);
  for (int i = 1; i <= ind; ++i) {
    if (dgr[i] > 1 && (!vis[i])) {
      dfs(i, 0);
      ans -= f[i];
    }
  }
  printf("%d", ans);
  return 0;
}
