#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2017;
vector<int> G[MAXN], nG[MAXN];
vector<int> V;
int N, M, ans, Bcnt, Dindex, Stop, Ccnt;
int DFN[MAXN], LOW[MAXN], Belong[MAXN], Stap[MAXN], Led[MAXN];
int vis[MAXN], Cnt[MAXN], far[MAXN], lea[MAXN];
bool instack[MAXN];
void Tarjan(int x, int Fa) {
  int j;
  DFN[x] = LOW[x] = ++Dindex;
  instack[x] = 1;
  Stap[++Stop] = x;
  for (int i = 0; i < G[x].size(); i++) {
    j = G[x][i];
    if (j == Fa) continue;
    if (!DFN[j]) {
      Tarjan(j, x);
      if (LOW[j] < LOW[x]) LOW[x] = LOW[j];
    } else if (instack[j] && DFN[j] < LOW[x])
      LOW[x] = DFN[j];
  }
  if (DFN[x] == LOW[x]) {
    Bcnt++;
    do {
      j = Stap[Stop--];
      instack[j] = 0;
      Belong[j] = Bcnt;
      Led[Bcnt] = j;
    } while (j != x);
  }
}
int MAX = -1, Far = 0;
void DFS(int x, int Fa, bool T, int D) {
  vis[x] = Ccnt;
  if (T) {
    Cnt[Ccnt]++;
    if (nG[x].size() == 0 || nG[x].size() == 1) lea[Ccnt]++;
  }
  if (D > MAX) {
    MAX = D;
    Far = x;
  }
  int j;
  for (int i = 0; i < nG[x].size(); i++) {
    j = nG[x][i];
    if (j == Fa) continue;
    if (!vis[j]) DFS(j, x, T, D + 1);
  }
}
int main() {
  scanf("%d%d", &N, &M);
  int a, b;
  for (int i = 0; i < M; i++) {
    scanf("%d%d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = 1; i <= N; i++)
    if (!DFN[i]) Tarjan(i, 0);
  for (int i = 1; i <= N; i++)
    for (int j = 0; j < G[i].size(); j++) {
      int to = G[i][j];
      if (Belong[i] != Belong[to]) {
        nG[Led[Belong[i]]].push_back(Led[Belong[to]]);
      }
    }
  sort(Belong + 1, Belong + 1 + N);
  for (int i = 2; i <= N; i++)
    if (Belong[i] == Belong[i - 1]) ans++;
  N = Bcnt;
  for (int i = 1; i <= N; i++) V.push_back(Led[i]);
  for (int i = 0; i < N; i++) {
    if (!vis[V[i]]) {
      Ccnt++;
      Far = 0, MAX = -1;
      DFS(V[i], 0, 1, 1);
      int res = Far;
      memset(vis, 0, sizeof(vis));
      Far = 0, MAX = -1;
      DFS(res, 0, 0, 1);
      ans += Cnt[Ccnt] - lea[Ccnt] - MAX + 2;
    }
  }
  ans += Ccnt - 1;
  for (int i = 0; i < N; i++)
    if (nG[V[i]].size() == 0) ans--;
  printf("%d", ans);
  return 0;
}
