#include <bits/stdc++.h>
using namespace std;
struct ST {
  int pp[2020], xu[2020];
  ST(int n) {
    for (int i = 0; i < n; i++) {
      pp[i] = i;
      xu[i] = i;
    }
  }
  int gg(int x) {
    if (pp[x] != x) {
      pp[x] = gg(pp[x]);
    }
    return pp[x];
  }
  void ct(int x, int y) {
    int rx = gg(x), ry = gg(y);
    if (rx == ry) {
      return;
    }
    if (xu[rx] > xu[ry]) {
      pp[ry] = rx;
      xu[rx] += xu[ry];
    } else {
      pp[rx] = ry;
      xu[ry] += xu[rx];
    }
  }
};
int n, m, nn, id[2020], lw[2020], C;
bool v[2020][2020], vis[2020], tr[2020][2020];
map<int, int> mp;
int dfs(int x, int y) {
  int rt = C;
  id[x] = C;
  C++;
  for (int i = 0; i < n; i++) {
    if (i != y && v[x][i]) {
      if (id[i] != -1) {
        rt = min(rt, id[i]);
      } else {
        rt = min(rt, dfs(i, x));
      }
    }
  }
  lw[x] = rt;
  return rt;
}
void js() {
  for (int i = 0; i < n; i++) {
    id[i] = -1;
  }
  for (int i = 0; i < n; i++) {
    if (id[i] == -1) {
      dfs(i, -1);
    }
  }
}
void dfs1(int x, int y, int &ll, int &d) {
  vis[x] = true;
  ll = x;
  d = 0;
  for (int i = 0; i < nn; i++) {
    if (i != y && tr[x][i]) {
      int lll, dd;
      dfs1(i, x, lll, dd);
      if (dd + 1 > d) {
        d = dd + 1;
        ll = lll;
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    v[x][y] = true;
    v[y][x] = true;
  }
  js();
  ST f(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (v[i][j] && id[i] < id[j] && lw[j] < id[j]) {
        f.ct(i, j);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    mp[f.gg(i)] = 0;
  }
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    it->second = nn;
    nn++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (v[i][j] && id[i] < id[j] && lw[j] == id[j]) {
        tr[mp[f.gg(i)]][mp[f.gg(j)]] = true;
        tr[mp[f.gg(j)]][mp[f.gg(i)]] = true;
      }
    }
  }
  int ans = n - 1;
  for (int i = 0; i < nn; i++) {
    int al = 0;
    for (int j = 0; j < nn; j++) {
      if (tr[i][j]) {
        al++;
      }
    }
    if (al == 1) {
      ans--;
    } else if (al == 0) {
      ans -= 2;
    }
  }
  for (int i = 0; i < nn; i++) {
    if (!vis[i]) {
      int x, y, z;
      dfs1(i, -1, x, z);
      dfs1(x, -1, y, z);
      ans -= z - 2;
    }
  }
  cout << ans << endl;
  return 0;
}
