#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
vector<int> nei[maxn], stk;
int dfn[maxn], low[maxn], ind;
int col[maxn], colors, ans;
void Tarjan(int root, int pre) {
  dfn[root] = low[root] = ++ind;
  stk.push_back(root);
  for (int i = 0; i < (int)nei[root].size(); i++) {
    int next = nei[root][i];
    if (next == pre) continue;
    if (!dfn[next]) {
      Tarjan(next, root);
      low[root] = min(low[root], low[next]);
    } else
      low[root] = min(low[root], dfn[next]);
  }
  if (dfn[root] == low[root]) {
    colors++;
    while (stk.back() != root) {
      col[stk.back()] = colors;
      stk.pop_back();
      ans++;
    }
    col[stk.back()] = colors;
    stk.pop_back();
  }
  return;
}
int indx, que[maxn];
vector<int> adj[maxn], blocks[maxn];
bool vis[maxn];
void bfs(int root) {
  indx++;
  int head = 0, tail = 0;
  que[tail++] = root;
  blocks[indx].push_back(root);
  vis[root] = true;
  while (head < tail) {
    int cur = que[head];
    head++;
    for (int i = 0; i < (int)adj[cur].size(); i++) {
      int next = adj[cur][i];
      if (vis[next]) continue;
      que[tail++] = next;
      blocks[indx].push_back(next);
      vis[next] = true;
    }
  }
  return;
}
pair<int, int> dfs(int root, int f) {
  pair<int, int> res = make_pair(root, 1);
  for (int i = 0; i < (int)adj[root].size(); i++) {
    int next = adj[root][i];
    if (next == f) continue;
    pair<int, int> cur = dfs(next, root);
    cur.second++;
    if (cur.second > res.second) res = cur;
  }
  return res;
}
int D(int root) {
  pair<int, int> one = dfs(root, 0);
  pair<int, int> two = dfs(one.first, 0);
  return two.second;
}
void solve(int c) {
  if ((int)blocks[c].size() == 1) return;
  int res = D(blocks[c][0]);
  for (int i = 0; i < (int)blocks[c].size(); i++)
    if ((int)adj[blocks[c][i]].size() == 1) res++;
  ans += (int)blocks[c].size() - (res - 2);
  return;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    nei[u].push_back(v);
    nei[v].push_back(u);
  }
  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 < (int)nei[i].size(); j++) {
      int u = i, v = nei[i][j];
      int u_ = col[u], v_ = col[v];
      if (u_ != v_) {
        adj[u_].push_back(v_);
        adj[v_].push_back(u_);
      }
    }
  for (int i = 1; i <= n; i++) {
    sort(adj[i].begin(), adj[i].end());
    adj[i].resize(unique(adj[i].begin(), adj[i].end()) - adj[i].begin());
  }
  for (int i = 1; i <= colors; i++)
    if (!vis[i]) bfs(i);
  for (int i = 1; i <= indx; i++) solve(i);
  ans += indx - 1;
  printf("%d\n", ans);
  return 0;
}
