#include <bits/stdc++.h>
using namespace std;
int dfn[2100], low[2100], tim, dis[2100], n, i, x, y, M, be[2100], m, j, ans,
    du[2100];
vector<int> E[2100], e[2100], q;
void tarjan(int x, int ff) {
  dfn[x] = low[x] = ++tim;
  q.push_back(x);
  for (int i = 0; i < e[x].size(); ++i)
    if (e[x][i] != ff) {
      if (!dfn[e[x][i]]) {
        tarjan(e[x][i], x);
        low[x] = min(low[x], low[e[x][i]]);
      } else
        low[x] = min(low[x], dfn[e[x][i]]);
    }
  if (low[x] == dfn[x]) {
    ++M;
    for (;;) {
      int t = q.back();
      q.pop_back();
      be[t] = M;
      if (t == x) break;
    }
  }
}
void dfs(int p, int ff, int dis) {
  dfn[p] = 1;
  if (dis > y) y = dis, x = p;
  for (int i = 0; i < E[p].size(); ++i)
    if (E[p][i] != ff) dfs(E[p][i], p, dis + 1);
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  for (i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i, 0);
  for (i = 1; i <= n; ++i)
    for (j = 0; j < e[i].size(); ++j)
      if (be[i] != be[e[i][j]]) E[be[i]].push_back(be[e[i][j]]), du[be[i]]++;
  memset(dfn, 0, sizeof(dfn));
  for (i = 1; i <= M; ++i) {
    if (!dfn[i]) {
      y = 0;
      dfs(i, 0, 1);
      y = 0;
      dfs(x, 0, 1);
      if (y == 1)
        ans--;
      else
        ans += y - 2 - 1;
    }
    if (du[i] <= 1) ans++;
  }
  printf("%d\n", n - ans - 1);
}
