#include <bits/stdc++.h>
using namespace std;
void read(int& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
char getc() {
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  return c;
}
const int N = 2010;
const int M = 2000010;
const int inf = 1000000000;
int n, m, i, j, k, l, p, x, y, cnt, res, ans;
int edge, e[M], b[M], fir[N], last[N];
void clear() {
  edge = 0;
  memset(b, -1, sizeof(b));
  memset(fir, -1, sizeof(fir));
}
void add(int x, int y) {
  e[edge] = y;
  if (fir[x] == -1)
    fir[x] = edge;
  else
    b[last[x]] = edge;
  last[x] = edge++;
}
int dfn[N], low[N], st[N], col[N], size[N], ti, co;
void dfs(int i, int f) {
  dfn[i] = low[i] = ++ti;
  st[++st[0]] = i;
  for (int k = fir[i]; k >= 0; k = b[k])
    if (e[k] != f)
      if (!dfn[e[k]])
        dfs(e[k], i), low[i] = min(low[i], low[e[k]]);
      else if (!col[e[k]])
        low[i] = min(low[i], dfn[e[k]]);
  if (dfn[i] == low[i]) {
    ++co;
    while (st[st[0] + 1] != i) col[st[st[0]--]] = co, size[co]++;
    cnt += size[co] - 1;
  }
}
int g[N][N];
bool G[N][N];
bool vis[N];
int q[N], fa[N], ch[N], leaf[N];
void go(int i, int t) {
  int k;
  for (k = 1; k <= g[i][0]; k++)
    if (g[i][k] != fa[i]) t += size[g[i][k]] - leaf[g[i][k]];
  res = min(res, t);
  for (k = 1; k <= g[i][0]; k++)
    if (g[i][k] != fa[i]) go(g[i][k], t - (size[g[i][k]] - leaf[g[i][k]]));
}
void bfs(int s) {
  int i, j, k, u;
  memset(fa, 0, sizeof(fa));
  q[1] = s;
  memset(size, 0, sizeof(size));
  memset(ch, 0, sizeof(ch));
  memset(leaf, 0, sizeof(leaf));
  for (i = j = 1; i <= j; i++) {
    u = q[i];
    for (k = 1; k <= g[u][0]; k++)
      if (g[u][k] != fa[u]) ch[u]++, fa[g[u][k]] = u, q[++j] = g[u][k];
  }
  for (i = j; i >= 1; i--) {
    u = q[i];
    size[u]++;
    if (ch[u] == 0) leaf[u]++;
    leaf[fa[u]] += leaf[u];
    size[fa[u]] += size[u];
  }
  go(s, 0);
}
void work(int i) {
  st[++st[0]] = i;
  vis[i] = 1;
  int k;
  for (k = 1; k <= g[i][0]; k++)
    if (!vis[g[i][k]]) work(g[i][k]);
}
int main() {
  read(n);
  read(m);
  clear();
  for (i = 1; i <= m; i++) read(x), read(y), add(x, y), add(y, x);
  ;
  cnt = 0;
  for (i = 1; i <= n; i++)
    if (!dfn[i]) dfs(i, 0), cnt++;
  cnt--;
  for (i = 1; i <= n; i++) {
    for (k = fir[i]; k >= 0; k = b[k])
      if (col[i] != col[e[k]] && (!G[col[i]][col[e[k]]])) {
        x = col[i];
        y = col[e[k]];
        g[x][++g[x][0]] = y;
        g[y][++g[y][0]] = x;
        G[x][y] = G[y][x] = 1;
      }
  }
  ans = cnt;
  for (i = 1; i <= co; i++)
    if (!vis[i]) {
      st[0] = 0;
      work(i);
      res = inf;
      for (j = 1; j <= st[0]; j++) bfs(st[j]);
      ans += res;
    }
  printf("%d\n", ans);
  scanf("\n");
  return 0;
}
