#include <bits/stdc++.h>
using namespace std;
const int MN = 2000 + 90;
int h[MN];
int par[MN];
bool mark[MN];
vector<int> adj[MN];
vector<pair<int, int>> edges;
vector<int> adj2[MN];
int cat[MN];
int star[MN];
vector<int> cmps[MN];
int cmp;
int ans;
int root(int v) { return par[v] == v ? v : par[v] = root(par[v]); }
void merg(int u, int v) {
  if (root(v) == root(u)) return;
  par[root(v)] = root(u);
  ans++;
}
int dfs(int v, int p) {
  mark[v] = true;
  int mx = h[v];
  for (int i : adj[v]) {
    if (!mark[i]) {
      h[i] = h[v] + 1;
      mx = min(mx, dfs(i, v));
    } else if (i != p) {
      mx = min(mx, h[i]);
    }
  }
  if (mx < h[v]) merg(v, p);
  return mx;
}
void dfs1(int v, int p) {
  mark[v] = true;
  for (int i : adj2[v]) {
    if (i != p) dfs1(i, v);
  }
  cmps[cmp].push_back(v);
}
void dfss(int v, int p) {
  for (int i : adj2[v]) {
    if (i != p) {
      dfss(i, v);
      if (adj[i].size() > 1) {
        star[v] += star[i] + 1;
      }
    }
  }
}
int dfs2(int v, int p) {
  cat[v] = star[v];
  for (int i : adj2[v]) {
    if (i != p) {
      dfs2(i, v);
      if (adj[i].size() > 1)
        cat[v] = min(cat[v], star[v] - star[i] - 1 + cat[i]);
    }
  }
  return cat[v];
}
int main() {
  ios::sync_with_stdio(0);
  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);
    edges.push_back(make_pair(u, v));
  }
  iota(par, par + n, 0);
  for (int i = 0; i < n; i++) {
    if (!mark[i]) dfs(i, i);
  }
  for (int i = 0; i < m; i++) {
    int x = root(edges[i].first), y = root(edges[i].second);
    if (x != y) {
      adj2[x].push_back(y);
      adj2[y].push_back(x);
    }
  }
  memset(mark, 0, sizeof mark);
  for (int i = 0; i < n; i++) {
    int u = root(i);
    if (!mark[u]) {
      dfs1(u, u);
      cmp++;
    }
  }
  for (int i = 0; i < cmp; i++) {
    int mx = cmps[i].size();
    for (int j : cmps[i]) {
      memset(star, 0, sizeof star);
      memset(cat, 0, sizeof cat);
      dfss(j, j);
      mx = min(mx, dfs2(j, j));
    }
    ans += mx;
  }
  ans += cmp - 1;
  cout << ans;
}
