#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
int N, M, minr[2100], dep[2100], dist[2100], res, nxt;
stack<pair<int, int> > st;
vector<int> adj[2100], adj2[2100];
int dfs(int n, int p, int d) {
  dep[n] = minr[n] = d;
  st.push(pair<int, int>(n, 0));
  for (int i = (0); i < (int((adj[n]).size())); i++) {
    int m = adj[n][i];
    if (m == p) continue;
    if (dep[m] == -1) {
      int dd = dfs(m, n, d + 1);
      minr[n] = min(minr[n], dd);
      if (dd == dep[m]) {
        res--;
        while (1) {
          pair<int, int> p = st.top();
          st.pop();
          if (p.second == 0) {
            res++;
          } else {
            adj2[nxt].push_back(p.first);
            adj2[p.first].push_back(nxt);
          }
          if (p.first == m && p.second == 0) break;
        }
        st.push(pair<int, int>(nxt++, 1));
      }
    } else {
      minr[n] = min(minr[n], dep[m]);
    }
  }
  return minr[n];
}
void bfs(int n) {
  for (int i = (0); i < (nxt); i++) dist[i] = oo;
  dist[n] = 0;
  queue<int> q;
  q.push(n);
  while (!q.empty()) {
    n = q.front();
    q.pop();
    for (int i = (0); i < (int((adj2[n]).size())); i++) {
      int m = adj2[n][i];
      if (dist[m] < oo) continue;
      dist[m] = dist[n] + 1;
      q.push(m);
    }
  }
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = (0); i < (M); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a - 1].push_back(b - 1);
    adj[b - 1].push_back(a - 1);
  }
  res = -1;
  memset(dep, -1, sizeof(dep));
  for (int i = (0); i < (N); i++) {
    if (dep[i] == -1) {
      res++;
      adj[N].clear();
      adj[N].push_back(i);
      while (!st.empty()) st.pop();
      nxt = 0;
      dfs(N, -1, 0);
      if (nxt == 1) continue;
      bfs(0);
      int imax = 0;
      for (int j = (1); j < (nxt); j++)
        if (dist[j] > dist[imax]) imax = j;
      bfs(imax);
      imax = 0;
      for (int j = (1); j < (nxt); j++)
        if (dist[j] > dist[imax]) imax = j;
      res += (nxt - dist[imax] + 1);
      for (int j = (0); j < (nxt); j++)
        if (int((adj2[j]).size()) == 1) res--;
      for (int j = (0); j < (nxt); j++) adj2[j].clear();
    }
  }
  printf("%d\n", res);
  return 0;
}
