#include <bits/stdc++.h>
using namespace std;
struct node {
  int begin, end, next;
} edge[100010 * 2], edge1[100010 * 2];
int cnt, Head[2010], cnt1, Head1[2010], DFN[2010], LOW[2010], STACK[2010], n, m,
    belong[2010], degree[2010], SCC, top, SIZE, from[2010], dis[2010], pp, gs;
bool INSTACK[2010], tag[2010], vis[2010], bj[2010];
int read() {
  int s = 0, fh = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + (ch - '0');
    ch = getchar();
  }
  return s * fh;
}
void addedge(int bb, int ee) {
  edge[++cnt].begin = bb;
  edge[cnt].end = ee;
  edge[cnt].next = Head[bb];
  Head[bb] = cnt;
}
void addedge1(int bb, int ee) {
  addedge(bb, ee);
  addedge(ee, bb);
}
void Addedge(int bb, int ee) {
  edge1[++cnt1].begin = bb;
  edge1[cnt1].end = ee;
  edge1[cnt1].next = Head1[bb];
  Head1[bb] = cnt1;
}
void Addedge1(int bb, int ee) {
  Addedge(bb, ee);
  Addedge(ee, bb);
}
void Tarjan(int u, int Last) {
  int i, v;
  DFN[u] = LOW[u] = ++SIZE;
  STACK[top++] = u;
  INSTACK[u] = true;
  for (i = Head[u]; i != -1; i = edge[i].next) {
    v = edge[i].end;
    if (i == (Last ^ 1)) continue;
    if (!DFN[v]) {
      Tarjan(v, i);
      LOW[u] = min(LOW[u], LOW[v]);
    } else if (INSTACK[v] == true)
      LOW[u] = min(LOW[u], DFN[v]);
  }
  if (DFN[u] == LOW[u]) {
    SCC++;
    do {
      v = STACK[--top];
      INSTACK[v] = false;
      belong[v] = SCC;
    } while (u != v);
  }
}
void Solve() {
  for (int i = 1; i <= n; i++)
    if (!DFN[i]) Tarjan(i, 0);
}
void dfs(int u, int fa) {
  int i, v;
  from[u] = fa;
  vis[u] = true;
  if (degree[u] == 1) {
    gs++;
    bj[u] = true;
  }
  if (dis[u] > dis[pp]) pp = u;
  for (i = Head1[u]; i != -1; i = edge1[i].next) {
    v = edge1[i].end;
    if (v == fa) continue;
    dis[v] = dis[u] + 1;
    dfs(v, u);
  }
}
int main() {
  int i, u, v, tot, Block, p1, p2, j;
  n = read();
  m = read();
  memset(Head, -1, sizeof(Head));
  cnt = 1;
  for (i = 1; i <= m; i++) {
    u = read();
    v = read();
    addedge1(u, v);
  }
  Solve();
  memset(Head1, -1, sizeof(Head1));
  cnt1 = 1;
  memset(degree, 0, sizeof(degree));
  for (i = 2; i <= cnt; i += 2) {
    if (belong[edge[i].begin] != belong[edge[i].end]) {
      Addedge1(belong[edge[i].begin], belong[edge[i].end]);
      degree[belong[edge[i].begin]]++;
      degree[belong[edge[i].end]]++;
    }
  }
  memset(vis, false, sizeof(vis));
  tot = 0;
  Block = 0;
  for (i = 1; i <= SCC; i++) {
    if (vis[i] == false) {
      Block++;
      gs = 0;
      pp = 0;
      memset(dis, 0, sizeof(dis));
      p1 = 0;
      memset(from, 0, sizeof(from));
      dfs(i, 0);
      p1 = pp;
      gs = 0;
      pp = 0;
      memset(dis, 0, sizeof(dis));
      p2 = 0;
      memset(from, 0, sizeof(from));
      memset(bj, false, sizeof(bj));
      dfs(p1, 0);
      p2 = pp;
      memset(tag, false, sizeof(tag));
      j = p2;
      while (1) {
        tag[j] = true;
        tot++;
        if (bj[j] == true) tot--;
        j = from[j];
        if (j == 0) break;
      }
      tot += gs;
    }
  }
  printf("%d", n - (tot - (Block - 1)));
  fclose(stdin);
  fclose(stdout);
  return 0;
}
