#include <bits/stdc++.h>
using namespace std;
int n, m, cnt = 0, head[20000 + 5];
int dfn[20000 + 5], low[20000 + 5], timestamp = 0;
struct edge {
  int end, next;
} e[200000 + 5];
struct node {
  int u, v;
} ee[200000 + 5];
int belong[20000 + 5], sum, siz[20000 + 5];
int f[20000 + 5], len[2][20000 + 5];
bool vis[100000 + 5];
void add_edge(int u, int v) {
  e[++cnt].end = v;
  e[cnt].next = head[u];
  head[u] = cnt;
}
bool cmp(node A, node B) { return A.u < B.u || (A.u == B.u && A.v < B.v); }
void dfs(int u, int from) {
  low[u] = dfn[u] = ++timestamp;
  vis[u] = true;
  for (int i = head[u]; i != 0; i = e[i].next) {
    int v = e[i].end;
    if ((from ^ 1) == i) continue;
    if (dfn[v] == 0) {
      dfs(v, i);
      low[u] = min(low[u], low[v]);
    } else if (vis[v])
      low[u] = min(low[u], dfn[v]);
  }
  vis[u] = false;
}
void dfs1(int u, int num) {
  belong[u] = num;
  sum++;
  for (int i = head[u]; i; i = e[i].next) {
    if (vis[i]) continue;
    int v = e[i].end;
    if (belong[v]) continue;
    dfs1(v, num);
  }
}
void dfs2(int u, int fa) {
  vis[u] = true;
  f[u] = len[1][u];
  int maxn1 = 0, maxn2 = 0;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].end;
    if (v == fa) continue;
    dfs2(v, u);
    if (siz[v] == 1) continue;
    if ((len[1][v] + 1) - f[v] > maxn1)
      maxn2 = maxn1, maxn1 = (len[1][v] + 1) - f[v];
    else if ((len[1][v] + 1) - f[v] > maxn2)
      maxn2 = (len[1][v] + 1) - f[v];
  }
  sum = min(sum, f[u] - maxn1 - maxn2 + len[0][u]);
  f[u] -= maxn1;
}
void dfs3(int u, int fa) {
  siz[u] = 1;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].end;
    if (v == fa) continue;
    dfs3(v, u);
    siz[u] += siz[v];
    if (siz[v] != 1) len[1][u] += len[1][v] + 1;
  }
}
void dfs4(int u, int fa) {
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].end;
    if (v == fa) continue;
    if (fa != 0) len[0][v] = (len[0][u] + 1);
    if (fa == 0 && siz[v] + 1 != siz[u]) len[0][v] = 1;
    len[0][v] += len[1][u];
    if (siz[v] != 1) len[0][v] -= len[1][v] + 1;
    dfs4(v, u);
  }
}
int main() {
  int i, j, A, B, tot = 0;
  long long ans = 0;
  scanf("%d%d", &n, &m);
  cnt = 1;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &A, &B);
    add_edge(A, B);
    add_edge(B, A);
  }
  memset(dfn, 0, sizeof(dfn));
  for (i = 1; i <= n; i++)
    if (!dfn[i]) dfs(i, 0);
  memset(vis, false, sizeof(vis));
  for (i = 1; i <= n; i++)
    for (j = head[i]; j; j = e[j].next)
      if (dfn[i] < low[e[j].end] || dfn[e[j].end] < low[i]) vis[j] = true;
  cnt = 0;
  for (i = 1; i <= n; i++)
    if (!belong[i]) {
      cnt++;
      sum = 0;
      dfs1(i, cnt);
      ans += sum - 1;
    }
  for (i = 1; i <= n; i++)
    for (j = head[i]; j; j = e[j].next)
      if (belong[i] != belong[e[j].end]) {
        ee[++tot].u = belong[i];
        ee[tot].v = belong[e[j].end];
        if (ee[tot].u > ee[tot].v) swap(ee[tot].u, ee[tot].v);
      }
  sort(ee + 1, ee + tot + 1, cmp);
  n = cnt;
  cnt = 0;
  memset(head, 0, sizeof(head));
  add_edge(ee[1].u, ee[1].v);
  add_edge(ee[1].v, ee[1].u);
  for (i = 2; i <= tot; i++) {
    if (ee[i].u == ee[i - 1].u && ee[i].v == ee[i - 1].v) continue;
    add_edge(ee[i].u, ee[i].v);
    add_edge(ee[i].v, ee[i].u);
  }
  memset(vis, false, sizeof(vis));
  for (i = 1; i <= n; i++)
    if (!vis[i]) {
      sum = 1e9;
      dfs3(i, 0);
      dfs4(i, 0);
      dfs2(i, 0);
      ans += sum + 1;
    }
  printf("%lld\n", ans - 1);
}
