#include <bits/stdc++.h>
const int ed = 111111;
const int vt = 2222;
struct edge {
  edge *nxt;
  int des;
  bool pd;
  void maker(edge *&a, int b) {
    nxt = a, des = b, pd = false;
    a = this;
  }
};
edge v[ed << 1], *sta[vt], *tot;
int sac[vt], tp, cnt, a[ed], b[ed], co[vt], lst[vt], h[vt], si[vt], fa[vt],
    res[vt], f[vt][vt], rc[vt];
bool pd[vt];
void cmin(int &a, int b) {
  if (b < a) a = b;
}
void cmax(int &a, int b) {
  if (b > a) a = b;
}
void dfs1(int now) {
  pd[now] = true;
  sac[++tp] = now;
  for (edge *e = sta[now]; e; e = e->nxt)
    if (!e->pd) {
      e->pd = v[e - v ^ 1].pd = true;
      if (!pd[e->des]) {
        lst[e->des] = h[e->des] = h[now] + 1;
        dfs1(e->des);
        cmin(lst[now], lst[e->des]);
      } else
        cmin(lst[now], h[e->des]);
    }
  if (lst[now] == h[now]) {
    ++cnt;
    do co[sac[tp]] = cnt;
    while (sac[tp--] != now);
  }
}
void dfs2(int now) {
  pd[now] = true;
  for (edge *e = sta[now]; e; e = e->nxt)
    if (!pd[e->des]) dfs2(e->des);
}
void dfs3(int now) {
  pd[now] = true, si[now] = res[now] = 1;
  int fs = 0, sc = 0;
  for (edge *e = sta[now]; e; e = e->nxt)
    if (!pd[e->des]) {
      dfs3(e->des);
      si[now] += si[e->des], cmax(res[now], res[e->des]);
      if (h[e->des] > fs) {
        sc = fs;
        fs = h[e->des];
      } else
        cmax(sc, h[e->des]);
    }
  h[now] = fs + 1;
  cmax(res[now], fs + sc + 1);
}
int main() {
  int n, m, i, j, ans;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) sta[i] = NULL, pd[i] = false;
  tot = v;
  for (i = 0; i < m; i++) {
    scanf("%d%d", a + i, b + i);
    (tot++)->maker(sta[a[i]], b[i]), (tot++)->maker(sta[b[i]], a[i]);
  }
  cnt = 0;
  for (i = 1; i <= n; i++)
    if (!pd[i]) {
      tp = 0, h[i] = 0, lst[i] = 0;
      dfs1(i);
    }
  for (i = 1; i <= cnt; i++)
    for (j = 1; j <= cnt; j++) f[i][j] = 0;
  for (i = 1; i <= cnt; i++)
    sta[i] = NULL, pd[i] = false, rc[i] = 0, f[i][i] = 1;
  tot = v, ans = n - cnt - 1;
  for (i = 0; i < m; i++) {
    a[i] = co[a[i]], b[i] = co[b[i]];
    if (!f[a[i]][b[i]]) {
      f[a[i]][b[i]] = f[b[i]][a[i]] = 1, rc[a[i]]++, rc[b[i]]++;
      (tot++)->maker(sta[a[i]], b[i]), (tot++)->maker(sta[b[i]], a[i]);
    }
  }
  for (i = 1; i <= cnt; i++)
    if (!pd[i]) ans++, dfs2(i);
  for (i = 1; i <= cnt; i++)
    for (j = 1; j <= cnt; j++) f[i][j] = 0;
  for (i = 1; i <= cnt; i++) sta[i] = NULL, pd[i] = false, f[i][i] = 1;
  tot = v;
  for (i = 0; i < m; i++)
    if (!f[a[i]][b[i]] && rc[a[i]] > 1 && rc[b[i]] > 1) {
      f[a[i]][b[i]] = f[b[i]][a[i]] = 1;
      (tot++)->maker(sta[a[i]], b[i]), (tot++)->maker(sta[b[i]], a[i]);
    }
  for (i = 1; i <= cnt; i++)
    if (rc[i] > 1 && !pd[i]) {
      dfs3(i);
      ans += si[i] - res[i];
    }
  printf("%d\n", ans);
  return 0;
}
