#include <bits/stdc++.h>
int e, i, N, M, Ans, res, f1, f2;
int X[100005], Y[100005], ed[200005], next[200005];
int f[2005][2], fa[2005], pa[2005], g[2005], v[2005], Cnt[2005], son[2005];
void Addedge(int i, int j) { ed[++e] = j, next[e] = son[i], son[i] = e; }
int getfather(int i) {
  if (fa[i] == i) return i;
  fa[i] = getfather(fa[i]);
  return fa[i];
}
void pre(int i, int last) {
  int j, k;
  pa[i] = last, g[i] = 1;
  for (j = son[i]; j; j = next[j])
    if (ed[j] != last)
      if (!g[ed[j]])
        pre(ed[j], i);
      else {
        f1 = getfather(i), f2 = getfather(ed[j]);
        if (f1 == f2) continue;
        for (k = i; k != ed[j]; k = pa[k]) {
          f1 = getfather(k), f2 = getfather(pa[k]);
          if (f1 != f2) fa[f1] = f2;
        }
      }
}
int Max(int a, int b) {
  if (a > b) return a;
  return b;
}
void Count(int i, int last) {
  int j;
  for (j = son[i]; j; j = next[j])
    if (ed[j] != last) {
      Count(ed[j], i);
      Cnt[i] += Max(Cnt[ed[j]], 1);
    }
}
void dfs(int i, int pre) {
  int j, Max1 = 0, Max2 = 0;
  v[i] = 1;
  for (j = son[i]; j; j = next[j])
    if (!v[ed[j]]) {
      dfs(ed[j], Max(pre + Cnt[i] - Max(Cnt[ed[j]], 1), 1));
      if (f[ed[j]][0] > f[i][0]) f[i][0] = f[ed[j]][0];
      if (f[ed[j]][1] - Cnt[ed[j]] > Max1)
        Max2 = Max1, Max1 = f[ed[j]][1] - Max(Cnt[ed[j]], 1);
      else if (f[ed[j]][1] - Cnt[ed[j]] > Max2)
        Max2 = f[ed[j]][1] - Max(Cnt[ed[j]], 1);
    }
  f[i][1] = Max1 + Cnt[i] + 1;
  if (Max1 + Max2 + Cnt[i] + 1 > f[i][0]) f[i][0] = Max1 + Max2 + Cnt[i] + 1;
  if (f[i][0] + pre > res) res = f[i][0] + pre;
}
int main() {
  scanf("%d%d", &N, &M);
  for (i = 1; i <= M; ++i) {
    scanf("%d%d", &X[i], &Y[i]);
    Addedge(X[i], Y[i]), Addedge(Y[i], X[i]);
  }
  for (i = 1; i <= N; ++i) fa[i] = i;
  for (i = 1; i <= N; ++i)
    if (!g[i]) pre(i, 0);
  e = 0;
  for (i = 0; i <= N; ++i) son[i] = 0;
  for (i = 1; i <= M; ++i) {
    f1 = getfather(X[i]), f2 = getfather(Y[i]);
    if (f1 != f2) Addedge(f1, f2), Addedge(f2, f1);
  }
  Ans = 1;
  for (i = 1; i <= N; ++i)
    if (!v[i] && getfather(i) == i)
      Count(i, 0), res = 0, dfs(i, 0), Ans += res - 1;
  printf("%d\n", N - Ans);
  return 0;
}
