#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long a = 0, b = getchar(), c = 1;
  while (!isdigit(b)) c = b == '-' ? -1 : 1, b = getchar();
  while (isdigit(b)) a = a * 10 + b - '0', b = getchar();
  return a * c;
}
int n, m, ab, ac, ad, res, a[2005], b[2005], c[2005], h[2005];
vector<int> e[2005], g[2005], v[2005];
int gao(int u, int y) {
  if (a[u]) return a[u];
  int x = a[u] = ++ab;
  c[++c[0]] = u;
  for (int i = 0; i < e[u].size(); i++)
    if (e[u][i] != y) x = min(x, gao(e[u][i], u));
  if (a[u] == x)
    for (++ac;;) {
      b[c[c[0]]] = ac;
      if (c[c[0]--] == u) break;
    }
  return x;
}
int dfs(int u, int y) {
  a[u] = 1;
  if (g[u].size() < 2) res++;
  int p = 0, q = 0, x = 0;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == y) continue;
    int z = dfs(v, u);
    if (z > p)
      q = p, p = z;
    else if (z > q)
      q = z;
  }
  x = p + 1;
  ad = max(ad, p + q + 1);
  return x;
}
void gg(int x, int y) {
  if (ab) return;
  b[x] = 1;
  h[x] = h[y] + 1, c[x] = h[x];
  bool z = 0;
  for (int i = 0; i < g[x].size(); i++)
    if (g[x][i] != y or z) {
      if (!b[g[x][i]]) gg(g[x][i], x);
      c[x] = min(c[x], c[g[x][i]]);
    } else
      z = 1;
  if (c[x] == h[x]) ab = 1;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    e[x].push_back(y);
    e[y].push_back(x);
  }
  for (int i = 1; i <= n; i++)
    if (!a[i]) gao(i, -1);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < e[i].size(); j++) {
      int k = e[i][j];
      if (b[k] == b[i]) continue;
      g[b[i]].push_back(b[k]);
    }
  memset(a, 0, sizeof(a));
  int c1 = 0, c2 = 0;
  for (int i = 1; i <= ac; i++) {
    if (a[i]) continue;
    ad = res = 0, dfs(i, -1);
    if (ad == 1 and res == 1)
      c1 += 1;
    else
      c1 += ad + res - 2;
    c2++;
  }
  gg(0, -1);
  cout << n - c1 + c2 - 1;
  return 0;
}
