#include <bits/stdc++.h>
using namespace std;
int n, m;
int size, leaf, maxLen;
int f[100005][2];
int totScc, tim, top;
int deg[100005], dfn[100005], low[100005], scc[100005], stk[100005];
int head[100005], nex[400005], to[400005], cntE;
bool inStack[100005];
struct edge {
  int u, v;
} e[400005];
inline void read(int &x) {
  x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
}
inline void ade(int u, int v) {
  to[++cntE] = v, ++deg[v];
  nex[cntE] = head[u], head[u] = cntE;
}
void tarjan(int u, int fa) {
  low[u] = dfn[u] = ++tim;
  stk[++top] = u, inStack[u] = true;
  for (int i = head[u], v; i; i = nex[i]) {
    v = to[i];
    if (v == fa) continue;
    if (dfn[v]) {
      if (inStack[v]) low[u] = min(low[u], dfn[v]);
    } else {
      tarjan(v, u);
      low[u] = min(low[u], low[v]);
    }
  }
  if (low[u] == dfn[u]) {
    ++totScc;
    do {
      int v = stk[top];
      scc[v] = totScc;
      inStack[v] = false;
    } while (stk[top--] != u);
  }
}
void dfs(int u) {
  dfn[u] = true, ++size;
  if (deg[u] == 1) ++leaf;
  for (int i = head[u], v; i; i = nex[i]) {
    v = to[i];
    if (dfn[v]) continue;
    dfs(v);
    if (f[u][1] < f[v][0]) {
      f[u][1] = f[v][0];
      if (f[u][0] < f[u][1]) swap(f[u][0], f[u][1]);
    }
  }
  ++f[u][0];
  maxLen = max(maxLen, f[u][0] + f[u][1]);
}
int main() {
  read(n), read(m);
  for (int i = 1; i <= m; ++i) {
    read(e[i].u), read(e[i].v);
    ade(e[i].u, e[i].v);
    ade(e[i].v, e[i].u);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) {
      tarjan(i, 0);
    }
  cntE = 0;
  memset(deg, 0, sizeof deg);
  memset(head, 0, sizeof head);
  for (int i = 1, u, v; i <= m; ++i) {
    u = scc[e[i].u], v = scc[e[i].v];
    if (u == v) continue;
    ade(u, v), ade(v, u);
  }
  memset(dfn, 0, sizeof dfn);
  int block(0), ans = n - totScc;
  for (int i = 1; i <= totScc; ++i)
    if (!dfn[i]) {
      ++block;
      size = leaf = maxLen = 0;
      dfs(i);
      if (size > 2) {
        ans += size - (maxLen + leaf - 2);
      }
    }
  printf("%d\n", ans + block - 1);
  return 0;
}
