#include <bits/stdc++.h>
using namespace std;
vector<int> v[2005], vv[2005], e;
int was[2005], g[2005][2005], gg[2005][2005], b[2005], cnt[2005], leaf[2005],
    res[2005];
void dfs(int u) {
  was[u] = 1;
  for (int i = 0; i < v[u].size(); i++) {
    int j = v[u][i];
    if (!was[j]) {
      g[u][j] = 2;
      dfs(j);
    }
  }
  e.push_back(u);
}
void dfs(int u, int r) {
  was[u] = 1;
  b[u] = r;
  for (int i = 0; i < v[u].size(); i++) {
    int j = v[u][i];
    if (!was[j] && (g[u][j] == 1)) dfs(j, r);
  }
}
void go(int u, int p) {
  cnt[u] = 1;
  leaf[u] = 0;
  int ii = 1;
  for (int i = 0; i < vv[u].size(); i++) {
    int j = vv[u][i];
    if (j == p) continue;
    go(j, u);
    ii = 0;
    cnt[u] += cnt[j];
    leaf[u] += leaf[j];
  }
  leaf[u] += ii;
  res[u] = cnt[u] - leaf[u];
  int cur = res[u];
  for (int i = 0; i < vv[u].size(); i++) {
    int j = vv[u][i];
    if (j != p)
      cur = min(cur, res[j] + (cnt[u] - leaf[u]) - (cnt[j] - leaf[j]) - 1);
  }
  res[u] = cur;
}
void go1(int u, int p) {
  was[u] = 1;
  for (int i = 0; i < vv[u].size(); i++) {
    int j = vv[u][i];
    if (j != p) go1(j, u);
  }
  if (vv[u].size() < 2) e.push_back(u);
}
int main() {
  int i, j, k, n, m;
  while (~scanf("%d%d", &n, &m)) {
    for (i = 1; i <= n; i++) v[i].clear(), vv[i].clear();
    memset(g, 0, sizeof(g));
    for (i = 1; i <= m; i++) {
      scanf("%d%d", &j, &k);
      v[j].push_back(k);
      v[k].push_back(j);
      g[j][k] = g[k][j] = 1;
    }
    memset(was, 0, sizeof(was));
    e.clear();
    for (i = 1; i <= n; i++)
      if (!was[i]) dfs(i);
    reverse((e).begin(), (e).end());
    memset(was, 0, sizeof(was));
    int r = 0;
    for (i = 0; i < e.size(); i++)
      if (!was[e[i]]) {
        dfs(e[i], r);
        r++;
      }
    int ans = n - r;
    memset(gg, 0, sizeof(gg));
    for (i = 1; i <= n; i++) {
      int x = b[i], y;
      for (j = 0; j < v[i].size(); j++) {
        int k = v[i][j], y = b[k];
        if (x != y && !gg[x][y]) {
          gg[x][y] = gg[y][x] = 1;
          vv[x].push_back(y);
          vv[y].push_back(x);
        }
      }
    }
    memset(was, 0, sizeof(was));
    for (i = 0; i < r; i++)
      if (!was[i]) {
        e.clear();
        go1(i, i);
        int tmp = n;
        for (j = 0; j < e.size(); j++) {
          int x = e[j];
          go(x, x);
          tmp = min(tmp, res[x]);
        }
        ans += tmp + 1;
      }
    printf("%d\n", ans - 1);
  }
  return 0;
}
