#include <bits/stdc++.h>
using namespace std;
int n, m;
const int maxn = 2000;
vector<int> edge[maxn];
vector<int> tree[maxn];
int vis[maxn], A[maxn], D[maxn];
int deg[maxn], idx[maxn], st[maxn], sp;
void dfs(int u, int pre, int deep, int &m) {
  vis[u] = 1;
  A[u] = D[u] = deep;
  st[sp++] = u;
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i];
    if (v == pre) continue;
    if (vis[v] == 1) {
      A[u] = min(A[u], D[v]);
    } else if (vis[v] == -1) {
      dfs(v, u, deep + 1, m);
      A[u] = min(A[u], A[v]);
      if (A[v] > D[u]) {
        do {
          idx[st[--sp]] = m;
        } while (st[sp] != v);
        m++;
      }
    }
  }
  vis[u] = 2;
}
int clearCircle() {
  memset(vis, -1, sizeof(vis));
  int m = 0;
  for (int i = 0; i < n; i++) {
    if (vis[i] != -1) continue;
    sp = 0;
    dfs(i, -1, 0, m);
    while (sp) idx[st[--sp]] = m;
    m++;
  }
  for (int u = 0; u < n; u++) {
    for (int j = 0; j < edge[u].size(); j++) {
      int v = edge[u][j];
      if (idx[u] != idx[v]) {
        tree[idx[u]].push_back(idx[v]);
        deg[idx[u]]++;
      }
    }
  }
  return m;
}
int max1[maxn], max2[maxn];
int leave;
int dfs(int u) {
  int add = 0;
  if (deg[u] > 1)
    add = 1;
  else
    leave++;
  int ret = 0;
  for (int i = 0; i < tree[u].size(); i++) {
    int v = tree[u][i];
    if (vis[v] != -1) continue;
    vis[v] = 1;
    ret = max(ret, dfs(v));
    if (max1[u] < max1[v]) {
      max2[u] = max1[u];
      max1[u] = max1[v];
    } else if (max2[u] < max1[v]) {
      max2[u] = max1[v];
    }
  }
  max1[u] += add;
  ret = max(ret, max1[u] + max2[u]);
  return ret;
}
int main() {
  cin >> n >> m;
  while (m--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  m = n;
  n = clearCircle();
  int ans = m - n;
  memset(vis, -1, sizeof(vis));
  ans += n;
  for (int i = 0; i < n; i++) {
    if (vis[i] != -1) continue;
    vis[i] = 1;
    leave = 0;
    ans -= leave + dfs(i) - 1;
  }
  cout << ans - 1 << endl;
  return 0;
}
