#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int n, m, num[2010], depth[2010], dist[2010], len = 0, ans;
bool vis[2010];
stack<int> st;
vector<int> g[2010];
vector<pair<int, int> > e;
int dfs(int pos, int no, int d) {
  depth[pos] = d;
  vis[pos] = true;
  st.push(pos);
  int low = d;
  for (int i = 0; i < g[pos].size(); i++) {
    if (g[pos][i] == no) continue;
    if (depth[g[pos][i]] < d)
      low = min(low, depth[g[pos][i]]);
    else if (!vis[g[pos][i]])
      low = min(low, dfs(g[pos][i], pos, d + 1));
  }
  if (low == d) {
    len++;
    while (true) {
      int tmp = st.top();
      st.pop();
      num[tmp] = len;
      if (tmp == pos) break;
    }
  }
  return low;
}
void dfs2(int pos, int no, int d) {
  vis[pos] = true;
  dist[pos] = d;
  for (int i = 0; i < g[pos].size(); i++)
    if (g[pos][i] != no) dfs2(g[pos][i], pos, d + 1);
}
int getD(int s) {
  for (int i = 0; i < 2005; i++) dist[i] = -1;
  dfs2(s, 0, 0);
  int mx = -1, root;
  for (int i = 1; i <= len; i++) {
    if (dist[i] > mx) {
      mx = dist[i];
      root = i;
    }
  }
  for (int i = 0; i < 2005; i++) dist[i] = -1;
  dfs2(root, 0, 0);
  mx = -1;
  for (int i = 1; i <= len; i++) mx = max(mx, dist[i]);
  return mx;
}
int main() {
  cin >> n >> m;
  int x, y;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
    e.push_back(make_pair(x, y));
  }
  for (int i = 0; i < n + 5; i++) depth[i] = 1e9;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    dfs(i, 0, 0);
  }
  for (int i = 0; i < n + 5; i++) g[i].clear();
  for (int i = 0; i < m; i++) {
    if (num[e[i].first] == num[e[i].second]) continue;
    g[num[e[i].first]].push_back(num[e[i].second]);
    g[num[e[i].second]].push_back(num[e[i].first]);
  }
  for (int i = 1; i <= len; i++) {
    sort(g[i].begin(), g[i].end());
    g[i].erase(unique(g[i].begin(), g[i].end()), g[i].end());
    if (g[i].size() == 1 || g[i].size() == 0) ans--;
  }
  if (ans == 0) ans = -1;
  ans += n;
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= len; i++) {
    if (vis[i]) continue;
    int d = getD(i);
    ans += 2 + (d > 0);
    ans -= d + 1;
  }
  cout << ans - 1 << endl;
  return 0;
}
