#include <bits/stdc++.h>
using namespace std;
int s, t, maxn;
int n, m;
int ans;
vector<int> ne[20010], G[20010];
int dfn[20010], low[20010], tim, vis[20010];
int q[20010], top;
int col, num[20010];
void dfs(int u, int fa) {
  dfn[u] = low[u] = ++tim;
  q[++top] = u;
  for (int v : ne[u]) {
    if (v == fa) continue;
    if (!dfn[v])
      dfs(v, u), low[u] = min(low[u], low[v]);
    else
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    col++;
    while (q[top] != u) num[q[top--]] = col;
    num[q[top--]] = col;
  }
}
void dfst(int u, int fa, int dep) {
  vis[u] = 1;
  if (dep > maxn) maxn = dep, t = u;
  for (int v : G[u]) {
    if (v == fa) continue;
    dfst(v, u, dep + 1);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  ans = n - 1;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    ne[x].push_back(y);
    ne[y].push_back(x);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) dfs(i, 0);
  for (int i = 1; i <= n; i++)
    for (int j : ne[i])
      if (num[i] != num[j]) G[num[i]].push_back(num[j]);
  for (int i = 1; i <= col; i++) {
    if (!G[i].size()) continue;
    if (G[i].size() == 1) ans--;
    if (!vis[i]) {
      maxn = 0;
      s = t = i;
      dfst(s, 0, 0);
      s = t;
      maxn = 0;
      dfst(s, 0, 0);
      ans -= maxn - 2;
    }
  }
  printf("%d\n", ans);
}
