#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  int f(1);
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
template <typename T, typename... Args>
inline void read(T &x, Args &...args) {
  read(x);
  read(args...);
}
template <typename T>
void write(T x, int f = 1) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10, 0);
  putchar('0' + x % 10);
  if (f) puts("");
}
const int maxn = 20005;
const int maxm = 100005;
int n, m, tot, col[maxn], del[maxn];
int dfn[maxn], low[maxn];
int sta[maxn], top, in[maxn];
int hd[maxn], cnt = 1, N, mxd;
struct edge {
  int ed, nxt;
} e[2 * maxm];
vector<int> T[maxn];
void star(int u, int v) {
  e[++cnt] = (edge){v, hd[u]};
  hd[u] = cnt;
  e[++cnt] = (edge){u, hd[v]};
  hd[v] = cnt;
}
void Tarjan(int x, int fa) {
  dfn[x] = low[x] = ++tot;
  sta[++top] = x;
  in[tot] = x;
  for (int i = hd[x]; i; i = e[i].nxt) {
    int y = e[i].ed;
    if (y == fa) continue;
    if (!dfn[y])
      Tarjan(y, x), low[x] = min(low[x], low[y]);
    else
      low[x] = min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    ++N;
    while (sta[top + 1] != x) col[sta[top--]] = N;
  }
}
int Dfs(int x, int fa) {
  if (del[x] <= 1) return 0;
  int mx = 0, Mx = 0;
  for (auto y : T[x]) {
    if (y == fa) continue;
    int ds = Dfs(y, x);
    if (ds > mx) swap(mx, ds);
    if (ds > Mx) swap(Mx, ds);
  }
  mxd = max(mxd, mx + Mx + 1);
  return mx + 1;
}
int main() {
  read(n, m);
  for (int i = 1, u, v; i <= m; ++i) read(u, v), star(u, v);
  int ANS = 1;
  for (int i(1); i <= n; ++i) {
    if (dfn[i]) continue;
    N = 0;
    tot = top = 0;
    Tarjan(i, 0);
    for (int i(1); i <= N; ++i) T[i].clear(), del[i] = 0;
    for (int i(1); i <= tot; ++i)
      for (int j = hd[in[i]]; j; j = e[j].nxt) {
        if (col[in[i]] == col[e[j].ed]) continue;
        T[col[in[i]]].emplace_back(col[e[j].ed]);
        ++del[col[in[i]]];
      }
    int rt = 0;
    for (int i(1); i <= N; ++i)
      if (del[i] <= 1)
        ++ANS;
      else
        rt = i;
    mxd = 0;
    Dfs(rt, 0);
    ANS += mxd - 1;
  }
  write(n - ANS);
  return 0;
}
