#include <bits/stdc++.h>
using namespace std;
const int maxN = 2005;
const int maxM = 100005;
struct edge {
  int a, l;
} e[maxM * 2], e2[maxM * 2];
int start[maxN], head[maxN], low[maxN], dfn[maxN], d[maxN];
int n, m, tot, w, p, c, t, ans, st[maxN], top, bl[maxN], der[maxN];
bool in[maxN], vis[maxN];
void add(int x, int y) {
  e[++tot].l = start[x];
  e[tot].a = y;
  start[x] = tot;
  e[++tot].l = start[y];
  e[tot].a = x;
  start[y] = tot;
}
void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++w;
  in[x] = 1;
  st[++top] = x;
  for (int i = start[x]; i; i = e[i].l) {
    int y = e[i].a;
    if (y == fa) continue;
    if (!dfn[y]) tarjan(y, x);
    if (in[y]) low[x] = ((low[x]) < (low[y]) ? (low[x]) : (low[y]));
  }
  if (low[x] == dfn[x]) {
    ++c;
    do {
      bl[st[top]] = c;
      in[st[top]] = 0;
      --top;
      ++ans;
    } while (st[top + 1] != x);
    --ans;
  }
}
void add2(int x, int y) {
  der[x]++;
  e2[++tot].l = head[x];
  e2[tot].a = y;
  head[x] = tot;
}
void init() {
  int x, y;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    add(x, y);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i, 0);
  tot = 0;
  for (int x = 1; x <= n; ++x)
    for (int i = start[x]; i; i = e[i].l)
      if (bl[x] != bl[e[i].a]) add2(bl[x], bl[e[i].a]);
}
void dfs(int x, int fa) {
  vis[x] = 1;
  ++t;
  if (d[x] > d[p]) p = x;
  for (int i = head[x]; i; i = e2[i].l)
    if (e2[i].a != fa) {
      d[e2[i].a] = d[x] + 1;
      dfs(e2[i].a, x);
    }
}
void make(int x) {
  p = x;
  d[x] = 1;
  dfs(x, 0);
  x = p;
  d[x] = 1;
  t = 0;
  dfs(x, 0);
  if (t == 1)
    ++ans;
  else
    ans = ans + t - d[p] + 3;
}
void work() {
  for (int i = 1; i <= c; ++i)
    if (!vis[i]) make(i);
  for (int i = 1; i <= c; ++i)
    if (der[i] == 1) --ans;
  --ans;
  printf("%d\n", ans);
}
int main() {
  init();
  work();
  return 0;
}
