#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m;
vector<int> nei[2005];
vector<int> bccnei[2005];
int dist[2005];
int timestamp;
int bccno[2005];
int bccnum[2005];
int bcccnt;
int dfn[2005];
int low[2005];
bool bridge[2005][2005];
bool vis[2005];
bool tree[2005];
void tarjan(int pos, int par) {
  timestamp++;
  dfn[pos] = low[pos] = timestamp;
  for (int to : nei[pos]) {
    if (!dfn[to]) {
      tarjan(to, pos);
      low[pos] = min(low[pos], low[to]);
      if (low[to] > dfn[pos]) {
        bridge[pos][to] = bridge[to][pos] = true;
      }
    } else if (dfn[to] < dfn[pos] && to != par) {
      low[pos] = min(low[pos], dfn[to]);
    }
  }
}
void dfs(int pos) {
  vis[pos] = true;
  bccno[pos] = bcccnt;
  for (int to : nei[pos]) {
    if (bridge[pos][to]) {
      continue;
    }
    if (!vis[to]) {
      dfs(to);
    }
  }
}
void ebcc() {
  for (int i = 0; i < n; i++) {
    if (!dfn[i]) {
      tarjan(i, -1);
    }
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      dfs(i);
      bcccnt++;
    }
  }
}
void runDis(int id) {
  memset(dist, -1, sizeof(dist));
  dist[id] = 0;
  queue<int> q;
  q.push(id);
  tree[id] = true;
  while (!q.empty()) {
    int last = q.front();
    q.pop();
    for (int to : bccnei[last]) {
      if (dist[to] == -1) {
        tree[to] = true;
        q.push(to);
        dist[to] = dist[last] + 1;
      }
    }
  }
}
int solveTree(int id) {
  runDis(id);
  int nodecnt = 0, maxid = -1, leaf = 0;
  for (int i = 0; i < bcccnt; i++) {
    if (dist[i] != -1) {
      nodecnt++;
      if (maxid == -1 || dist[i] > dist[maxid]) {
        maxid = i;
      }
      if (bccnei[i].size() == 1) {
        leaf++;
      }
    }
  }
  if (nodecnt == 1) {
    return 0;
  }
  runDis(maxid);
  int mxd = -1;
  for (int i = 0; i < n; i++) {
    mxd = max(mxd, dist[i]);
  }
  return nodecnt - leaf - mxd - 1 + 2;
}
int main(int argc, char* argv[]) {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    nei[a].push_back(b);
    nei[b].push_back(a);
  }
  ebcc();
  for (int i = 0; i < n; i++) {
    for (int to : nei[i]) {
      if (bccno[i] != bccno[to]) {
        bccnei[bccno[i]].push_back(bccno[to]);
        bccnei[bccno[to]].push_back(bccno[i]);
      }
    }
  }
  for (int i = 0; i < bcccnt; i++) {
    sort(bccnei[i].begin(), bccnei[i].end());
    bccnei[i].erase(unique(bccnei[i].begin(), bccnei[i].end()),
                    bccnei[i].end());
  }
  int tree = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    bccnum[bccno[i]]++;
  }
  for (int i = 0; i < bcccnt; i++) {
    ans += bccnum[i] - 1;
  }
  for (int i = 0; i < bcccnt; i++) {
    if (!::tree[i]) {
      ans += solveTree(i);
      tree++;
    }
  }
  ans += tree - 1;
  cout << ans << endl;
  return 0;
}
