#include <bits/stdc++.h>
template <class T>
T min(T x, T y) {
  return x < y ? x : y;
}
template <class T>
T max(T x, T y) {
  return x > y ? x : y;
}
int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return s * w;
}
struct Edge {
  int to, next;
} a[20010 << 5], e[20010 << 5];
int h[20010], cnt = 1, H[20010], CNT, dfn[20010], low[20010], dfx, tot,
              q[20010], be[20010], D[20010], v[20010];
void add(int x, int y) {
  a[++cnt] = (Edge){y, h[x]}, h[x] = cnt, a[++cnt] = (Edge){x, h[y]},
  h[y] = cnt;
}
void Tarjan(int x, int pre) {
  dfn[x] = low[x] = ++dfx, q[++q[0]] = x;
  for (int i = h[x]; i; i = a[i].next)
    if (i ^ pre)
      !dfn[a[i].to] ? Tarjan(a[i].to, i ^ 1) : void(0),
          low[x] = min(low[x], low[a[i].to]);
  if (dfn[x] == low[x]) {
    int y;
    ++tot;
    do {
      be[y = q[q[0]--]] = tot;
    } while (y ^ x);
  }
}
void ADD(int x, int y) {
  e[++CNT] = (Edge){y, H[x]}, H[x] = CNT, e[++CNT] = (Edge){x, H[y]},
  H[y] = CNT;
}
int n, m, mx, rt, res, red;
void Dfs(int x, int dep) {
  v[x] = 1;
  if (dep > mx) rt = x, mx = dep;
  for (int i = H[x]; i; i = e[i].next)
    if (!v[e[i].to]) Dfs(e[i].to, dep + 1);
}
void DFS(int x, int dep) {
  v[x] = 2, mx = max(mx, dep);
  for (int i = H[x]; i; i = e[i].next)
    if (v[e[i].to] ^ 2) DFS(e[i].to, dep + 1);
}
signed main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) add(read(), read());
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) Tarjan(i, 0);
  for (int i = 1; i <= n; i++)
    for (int j = h[i]; j; j = a[j].next)
      if (be[i] ^ be[a[j].to]) ADD(be[i], be[a[j].to]), ++D[be[i]];
  for (int i = 1; i <= n; i++) red += D[i] == 1;
  for (int i = 1; i <= tot; i++)
    if (!v[i] && D[i])
      mx = 0, Dfs(i, 1), mx = 0, DFS(rt, 1), red += mx - 2, ++res;
  printf("%d\n", res + n - red - 1);
  return 0;
}
