#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005, maxm = 200005;
vector<int> g[maxn];
int tmp, vis[maxn], dis[maxn], mp[maxn][maxn];
int n, m, ans, cnt, tot, res, ecnt, info[maxn], nx[maxm], v[maxm];
int id, en, dfn[maxn], low[maxn], ori[maxn], sta[maxn], outd[maxn];
void add(int u1, int v1) {
  nx[++ecnt] = info[u1];
  info[u1] = ecnt;
  v[ecnt] = v1;
}
void targin(int x, int fa) {
  dfn[x] = low[x] = ++id;
  sta[++en] = x;
  for (int i = info[x]; i; i = nx[i]) {
    if (v[i] == fa) continue;
    if (!dfn[v[i]])
      targin(v[i], x), low[x] = min(low[x], low[v[i]]);
    else
      low[x] = min(low[x], dfn[v[i]]);
  }
  if (low[x] == dfn[x]) {
    int v;
    cnt++;
    do v = sta[en--], ori[v] = cnt;
    while (v != x);
  }
}
void dfs(int x, int fa) {
  vis[x] = 1;
  dis[x] = dis[fa] + 1;
  if (dis[tmp] < dis[x]) tmp = x;
  for (int i = 0, lim = g[x].size(); i < lim; i++)
    if (g[x][i] != fa) dfs(g[x][i], x);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, u1, v1; i <= m; i++)
    scanf("%d%d", &u1, &v1), add(u1, v1), add(v1, u1);
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) targin(i, 0);
  if (cnt == 1) {
    printf("%d\n", n - 1);
    return 0;
  }
  for (int x = 1; x <= n; x++)
    for (int i = info[x]; i; i = nx[i])
      if (!mp[ori[x]][ori[v[i]]] && ori[x] != ori[v[i]]) {
        mp[ori[x]][ori[v[i]]] = 1;
        g[ori[x]].push_back(ori[v[i]]);
        outd[ori[x]]++;
      }
  for (int i = 1; i <= cnt; i++)
    if (outd[i] == 1) res++;
  for (int i = 1, p1, p2; i <= cnt; i++)
    if (!vis[i]) {
      tot++;
      tmp = 0;
      dfs(i, 0);
      p1 = tmp;
      tmp = 0;
      dfs(p1, 0);
      p2 = tmp;
      if (dis[p2] < 2)
        res++;
      else
        res += dis[p2] - 2;
    }
  printf("%d\n", n - res + tot - 1);
}
