#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> G[2005];
int dep[2005], low[2005];
stack<int> Stack;
int BCC = 0;
int ID[2005];
void dfs1(int u, int pa, int d) {
  dep[u] = low[u] = d;
  Stack.emplace(u);
  for (int v : G[u])
    if (v != pa) {
      if (dep[v] == -1) {
        dfs1(v, u, d + 1);
        low[u] = min(low[u], low[v]);
      } else
        low[u] = min(low[u], dep[v]);
    }
  if (dep[u] == low[u]) {
    BCC++;
    int now;
    do {
      now = Stack.top();
      Stack.pop();
      ID[now] = BCC;
    } while (now != u);
  }
}
vector<int> nG[2005];
set<pair<int, int> > S;
int sz[2005];
int dfs2(int u, int pa) {
  sz[u] = 1;
  if (nG[u].empty() || ((int)nG[u].size() == 1 && (nG[u][0] == pa || u == pa)))
    sz[u] = 0;
  for (int v : nG[u])
    if (v != pa) sz[u] += dfs2(v, u);
  return sz[u];
}
int dp[2005];
int minn = -1;
void dfs3(int u, int pa, int n) {
  int DP[] = {0, 0, 0};
  for (int v : nG[u])
    if (v != pa) {
      dfs3(v, u, n);
      DP[2] = min(DP[2] + sz[v], DP[1] + dp[v]);
      DP[1] = min(DP[1] + sz[v], DP[0] + dp[v]);
      DP[0] += sz[v];
    }
  int up_cost = n - sz[u];
  int down_cost = min(DP[1], DP[2]);
  if (minn == -1 || up_cost + down_cost < minn) minn = up_cost + down_cost;
  dp[u] = DP[1];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 0, u, v; i < M; i++) {
    cin >> u >> v;
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  memset(dep, -1, sizeof dep);
  for (int u = 1; u <= N; u++)
    if (dep[u] == -1) dfs1(u, u, 1);
  int ans = N - BCC;
  for (int u = 1; u <= N; u++)
    for (int v : G[u]) {
      int a = ID[u], b = ID[v];
      if (a > b) swap(a, b);
      if (a != b && S.count(pair<int, int>{a, b}) == 0) {
        nG[a].emplace_back(b);
        nG[b].emplace_back(a);
        S.emplace(pair<int, int>{a, b});
      }
    }
  memset(dp, -1, sizeof dp);
  bool first = true;
  for (int u = 1; u <= BCC; u++)
    if (dp[u] == -1) {
      minn = -1;
      dfs3(u, u, dfs2(u, u));
      ans += minn;
      if (!first) ans++;
      first = false;
    }
  cout << ans << endl;
  return 0;
}
