#include <bits/stdc++.h>
using namespace std;
const int MX = 2000 + 5;
const int MXE = 1e5 + 7;
const int inf = 0x3f3f3f3f;
int n, m;
struct edge {
  int u, v, nxt;
} E[MXE << 1];
int head[MX], tot;
vector<int> G[MX];
void init() {
  memset(head, -1, sizeof(head));
  tot = 0;
}
void add_edge(int u, int v) {
  E[tot].u = u;
  E[tot].v = v;
  E[tot].nxt = head[u];
  head[u] = tot++;
}
int dfn[MX], low[MX];
int Stack[MX], inStack[MX], belong[MX];
int dsz, ssz, bsz;
void tarjan(int u, int e) {
  inStack[u] = 1;
  Stack[++ssz] = u;
  dfn[u] = low[u] = ++dsz;
  for (int i = head[u]; ~i; i = E[i].nxt) {
    int v = E[i].v;
    if ((i ^ 1) == e) continue;
    if (!dfn[v]) {
      tarjan(v, i);
      low[u] = min(low[u], low[v]);
    } else if (inStack[v])
      low[u] = min(low[u], low[v]);
  }
  if (dfn[u] == low[u]) {
    bsz++;
    int v;
    do {
      v = Stack[ssz--];
      inStack[v] = 0;
      belong[v] = bsz;
    } while (ssz && u != v);
  }
}
void tarjan_solve() {
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i, -1);
  for (int i = 0; i < 2 * m; i += 2) {
    int u = E[i].u, v = E[i].v;
    u = belong[u];
    v = belong[v];
    if (u == v) continue;
    G[u].push_back(v);
    G[v].push_back(u);
  }
}
int vis[MX], sz[MX], all;
void dfs1(int u, int fa) {
  vis[u] = all;
  sz[all]++;
  for (auto v : G[u]) {
    if (v == fa) continue;
    dfs1(v, u);
  }
}
int MAX_dep;
int num[MX];
void dfs2(int u, int dep, int fa) {
  MAX_dep = max(MAX_dep, dep);
  for (auto v : G[u]) {
    if (v == fa || G[v].size() == 1) continue;
    dfs2(v, dep + 1, u);
  }
}
int main() {
  init();
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add_edge(u, v);
    add_edge(v, u);
  }
  tarjan_solve();
  int ans = n - bsz;
  for (int i = 1; i <= bsz; i++) {
    if (!vis[i]) all++, dfs1(i, 0);
  }
  for (int i = 1; i <= bsz; i++) {
    if (G[i].size() == 1)
      sz[vis[i]]--;
    else {
      MAX_dep = 0;
      dfs2(i, 1, 0);
      num[vis[i]] = max(num[vis[i]], MAX_dep);
    }
  }
  for (int i = 1; i <= all; i++) ans += sz[i] - num[i];
  printf("%d\n", ans + all - 1);
  return 0;
}
