#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return x * neg;
}
int n = read(), m = read();
vector<int> g[100005];
int dfn[100005], low[100005], tim = 0;
map<pair<int, int>, bool> bridge;
inline void tarjan(int x, int f) {
  dfn[x] = low[x] = ++tim;
  for (__typeof(g[x].begin()) it = g[x].begin(); it != g[x].end(); it++) {
    int y = *it;
    if (!dfn[y]) {
      tarjan(y, x);
      low[x] = min(low[x], low[y]);
      if (low[y] > dfn[x])
        bridge[pair<int, int>(x, y)] = bridge[pair<int, int>(y, x)] = 1;
    } else if (y != f)
      low[x] = min(low[x], dfn[y]);
  }
}
int ecc[100005], comp = 0, siz[100005];
inline void findcomp(int x) {
  if (ecc[x]) return;
  ecc[x] = comp;
  siz[comp]++;
  for (__typeof(g[x].begin()) it = g[x].begin(); it != g[x].end(); it++) {
    int y = *it;
    if (!bridge[pair<int, int>(x, y)]) findcomp(y);
  }
}
map<pair<int, int>, bool> edged;
vector<int> new_g[100005];
int dep1[100005], dep2[100005], vis[100005], deg[100005];
vector<int> points;
inline void dfs1(int x, int f) {
  points.push_back(x);
  vis[x] = 1;
  for (__typeof(new_g[x].begin()) it = new_g[x].begin(); it != new_g[x].end();
       it++) {
    int y = *it;
    if (y == f) continue;
    dep1[y] = dep1[x] + 1;
    dfs1(y, x);
  }
}
inline void dfs2(int x, int f) {
  for (__typeof(new_g[x].begin()) it = new_g[x].begin(); it != new_g[x].end();
       it++) {
    int y = *it;
    if (y == f) continue;
    dep2[y] = dep2[x] + 1;
    dfs2(y, x);
  }
}
signed main() {
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int ans = n - 1;
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i, 0);
  for (int i = 1; i <= n; i++)
    if (!ecc[i]) comp++, findcomp(i);
  for (int i = 1; i <= n; i++)
    for (__typeof(g[i].begin()) it = g[i].begin(); it != g[i].end(); it++) {
      int j = *it;
      if (ecc[i] != ecc[j] && !edged[pair<int, int>(ecc[i], ecc[j])]) {
        edged[pair<int, int>(ecc[i], ecc[j])] =
            edged[pair<int, int>(ecc[j], ecc[i])] = 1;
        new_g[ecc[i]].push_back(ecc[j]);
        new_g[ecc[j]].push_back(ecc[i]);
        deg[ecc[i]]++;
        deg[ecc[j]]++;
      }
    }
  for (int i = 1; i <= comp; i++) {
    if (deg[i] == 1)
      ans--;
    else if (deg[i] == 0)
      ans -= 2;
  }
  int t = 0;
  for (int i = 1; i <= comp; i++)
    if (!vis[i]) {
      points.clear();
      t++;
      dfs1(i, 0);
      int u = 0, v = 0;
      for (__typeof(points.begin()) j = points.begin(); j != points.end(); j++)
        if (dep1[*j] > dep1[u]) u = *j;
      dfs2(u, 0);
      for (__typeof(points.begin()) j = points.begin(); j != points.end(); j++)
        if (dep2[*j] > dep2[v]) v = *j;
      ans -= dep2[v] - 2;
    }
  printf("%d\n", ans);
  return 0;
}
