#include <bits/stdc++.h>
using namespace std;
int n, m, x[200001], y[200001], tag[200001], fi[200001 << 1], nt[200001 << 1],
    go[200001 << 1], root;
int cnt, top, low[200001], dfn[200001], id[200001], deg[200001], st[200001],
    ans, cntx, sum, maxx;
void add(int u, int v) {
  nt[++cnt] = fi[u];
  fi[u] = cnt;
  go[cnt] = v;
}
void tarjan(int u, int fa) {
  dfn[u] = ++cnt;
  low[u] = dfn[u];
  st[++top] = u;
  int t = 0;
  for (int i = fi[u]; i; i = nt[i]) {
    int v = go[i];
    if (v == fa && !t) {
      t++;
      continue;
    }
    if (dfn[v]) {
      low[u] = min(low[u], low[v]);
      continue;
    }
    tarjan(v, u);
    low[u] = min(low[u], low[v]);
  }
  if (low[u] == dfn[u]) {
    int y;
    while (y = st[top--]) {
      tag[y] = u;
      if (y == u) break;
    }
  }
}
void dfs1(int u, int dep) {
  dfn[u] = 1;
  for (int i = fi[u]; i; i = nt[i]) {
    int v = go[i];
    if (dfn[v]) continue;
    dfs1(v, dep + 1);
  }
  if (dep > maxx) root = u, maxx = dep;
}
void dfs2(int u, int dep, int fa) {
  for (int i = fi[u]; i; i = nt[i]) {
    int v = go[i];
    if (v == fa) continue;
    dfs2(v, dep + 1, u);
  }
  if (dep >= maxx) maxx = dep;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &x[i], &y[i]);
    add(x[i], y[i]);
    add(y[i], x[i]);
  }
  for (int i = 1; i <= n; i++) {
    top = 0;
    cnt = 0;
    if (!dfn[i]) tarjan(i, 0);
  }
  memset(fi, 0, sizeof fi);
  cnt = 0;
  top = 0;
  for (int i = 1; i <= n; i++)
    if (tag[i] == i) id[i] = ++top;
  for (int i = 1; i <= m; i++) {
    if (tag[x[i]] != tag[y[i]]) {
      add(id[tag[x[i]]], id[tag[y[i]]]), add(id[tag[y[i]]], id[tag[x[i]]]);
      deg[id[tag[x[i]]]]++;
      deg[id[tag[y[i]]]]++;
    }
  }
  for (int i = 1; i <= top; i++) {
    if (deg[i] == 1) ans++;
  }
  memset(dfn, 0, sizeof dfn);
  for (int i = 1; i <= top; i++) {
    if (!dfn[i] && deg[i] == 0) sum++, ans++;
    if (!dfn[i] && deg[i] != 0) {
      sum++;
      dfs1(i, 1), dfs2(root, 1, 0);
      root = 0;
      ans += maxx - 2;
      maxx = 0;
    }
  }
  sum--;
  ans = sum + n - ans;
  cout << ans << endl;
}
