#include <bits/stdc++.h>
using namespace std;
const int maxN = 2010, maxE = 1e5 + 10;
int best[maxN], h[maxN], cmp[maxN], cnt;
vector<int> adj[maxN], tree[maxN], g[maxN], r[maxN], topol, vc[maxN];
bool mark[maxN];
pair<int, int> e[maxE];
void DFS(int v) {
  mark[v] = true;
  for (auto u : adj[v]) {
    if (!mark[u]) {
      g[v].push_back(u);
      r[u].push_back(v);
      h[u] = h[v] + 1;
      DFS(u);
    } else if (h[u] < h[v] - 1)
      g[v].push_back(u), r[u].push_back(v);
  }
}
void sfd(int v) {
  mark[v] = true;
  cmp[v] = cnt;
  for (auto u : r[v])
    if (!mark[u]) sfd(u);
}
void dfs(int v) {
  mark[v] = true;
  for (auto u : g[v])
    if (!mark[u]) dfs(u);
  topol.push_back(v);
}
int BEST;
void comps(int v, int num) {
  mark[v] = true;
  vc[num].push_back(v);
  for (auto u : tree[v])
    if (!mark[u]) comps(u, num);
}
void solve(int v, int curr = 0, int par = -1) {
  BEST = max(BEST, curr);
  for (auto u : tree[v]) {
    if (u == par) continue;
    solve(u, curr + 1, v);
  }
  return;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
    e[i] = {u, v};
  }
  for (int i = 0; i < n; i++)
    if (!mark[i]) DFS(i);
  memset(mark, 0, sizeof mark);
  for (int i = 0; i < n; i++)
    if (!mark[i]) dfs(i);
  reverse(topol.begin(), topol.end());
  memset(mark, 0, sizeof mark);
  for (auto v : topol)
    if (!mark[v]) sfd(v), cnt++;
  for (int i = 0; i < m; i++) {
    int u = e[i].first, v = e[i].second;
    if (cmp[u] == cmp[v]) continue;
    tree[cmp[u]].push_back(cmp[v]);
    tree[cmp[v]].push_back(cmp[u]);
  }
  memset(mark, 0, sizeof mark);
  int z = 0;
  for (int i = 0; i < cnt; i++)
    if (!mark[i]) comps(i, z), z++;
  int ans = n - cnt;
  for (int i = 0; i < z; i++) {
    best[i] = 0;
    int nleaf = 0;
    for (auto v : vc[i]) {
      if (tree[v].size() > 1) nleaf++;
      BEST = 0;
      solve(v);
      best[i] = max(best[i], BEST);
    }
    if (best[i] > 0) ans += nleaf - best[i] + 1;
  }
  ans += (z - 1);
  cout << ans << endl;
}
