#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
struct node {
  int to, next;
} w[N << 1];
int cnt, tot, id[N], h[N], scc[N], dfn[N], low[N], instack[N], top, st[N],
    vis[N], res, maxx;
int n, m, du[N], sum, ans;
struct edge {
  int x, y;
} a[N << 1];
namespace IO {
const int maxm = 1000000;
char buf[maxm], *p1, *p2;
template <typename T>
__inline__ __attribute__((always_inline)) void redi(T &x) {
  static std::streambuf *inbuf = cin.rdbuf();
  x = 0;
  register int f = 0;
  register char ch =
      (p1 == p2 && (p2 = (p1 = buf) + inbuf->sgetn(buf, maxm), p1 == p2)
           ? EOF
           : *p1++);
  while (!std::isdigit(ch)) {
    if (ch == '-') f = 1;
    ch = (p1 == p2 && (p2 = (p1 = buf) + inbuf->sgetn(buf, maxm), p1 == p2)
              ? EOF
              : *p1++);
  }
  if (std::isdigit(ch))
    x = x * 10 + ch - '0',
    ch = (p1 == p2 && (p2 = (p1 = buf) + inbuf->sgetn(buf, maxm), p1 == p2)
              ? EOF
              : *p1++);
  while (std::isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = (p1 == p2 && (p2 = (p1 = buf) + inbuf->sgetn(buf, maxm), p1 == p2)
              ? EOF
              : *p1++);
  }
  x = f ? -x : x;
}
__inline__ __attribute__((always_inline)) void read(char asd[]) {
  static std::streambuf *inbuf = cin.rdbuf();
  char t = (p1 == p2 && (p2 = (p1 = buf) + inbuf->sgetn(buf, maxm), p1 == p2)
                ? EOF
                : *p1++);
  int u = 0;
  while (t == ' ' || t == '\n' || t == '\r')
    t = (p1 == p2 && (p2 = (p1 = buf) + inbuf->sgetn(buf, maxm), p1 == p2)
             ? EOF
             : *p1++);
  while (t != ' ' && t != '\n' && t != EOF && t != '\r')
    asd[u++] = t,
    t = (p1 == p2 && (p2 = (p1 = buf) + inbuf->sgetn(buf, maxm), p1 == p2)
             ? EOF
             : *p1++);
  asd[u] = '\0';
}
template <typename T, typename... Args>
__inline__ __attribute__((always_inline)) void redi(T &a, Args &...args) {
  redi(a);
  redi(args...);
}
char buf1[maxm + 9], a1[20];
int p, po = -1;
__inline__ __attribute__((always_inline)) void flush() {
  fwrite(buf1, 1, po + 1, stdout), po = -1;
}
__inline__ __attribute__((always_inline)) void print(long long x, char c) {
  if (po > maxm) flush();
  if (x < 0) buf1[++po] = 45, x = -x;
  do {
    a1[++p] = x % 10 + 48;
  } while (x /= 10);
  do {
    buf1[++po] = a1[p];
  } while (--p);
  buf1[++po] = c;
}
}  // namespace IO
using IO::flush;
using IO::print;
using IO::read;
using IO::redi;
__inline__ __attribute__((always_inline)) void addage(int x, int y) {
  cnt++;
  w[cnt].to = y;
  w[cnt].next = h[x];
  h[x] = cnt;
}
void tarjan(int u, int fa) {
  dfn[u] = low[u] = ++tot;
  st[++top] = u;
  int bj = 0;
  for (int i = h[u]; i; i = w[i].next) {
    int e = w[i].to;
    if (e == fa && bj == 0) {
      bj++;
      continue;
    }
    if (dfn[e]) {
      low[u] = min(low[u], low[e]);
      continue;
    }
    tarjan(e, u);
    low[u] = min(low[e], low[u]);
  }
  if (dfn[u] == low[u]) {
    int v;
    while (v = st[top--]) {
      scc[v] = u;
      if (v == u) break;
    }
  }
}
void DFS1(int u, int dep) {
  vis[u] = 1;
  for (int i = h[u]; i; i = w[i].next) {
    int e = w[i].to;
    if (!vis[e]) DFS1(e, dep + 1);
  }
  if (dep > maxx) {
    maxx = dep, res = u;
  }
}
void DFS2(int u, int dep, int fa) {
  for (int i = h[u]; i; i = w[i].next) {
    int e = w[i].to;
    if (e ^ fa) DFS2(e, dep + 1, u);
  }
  maxx = max(maxx, dep);
}
int main() {
  redi(n, m);
  for (register int i = 1; i <= m; i++) {
    redi(a[i].x, a[i].y);
    addage(a[i].x, a[i].y);
    addage(a[i].y, a[i].x);
  }
  for (register int i = 1; i <= n; i++) {
    top = 0;
    tot = 0;
    if (!dfn[i]) tarjan(i, 0);
  }
  memset(h, 0, sizeof(h));
  cnt = 0;
  top = 0;
  for (register int i = 1; i <= n; i++) {
    if (scc[i] == i) id[i] = ++top;
  }
  for (register int i = 1; i <= m; i++) {
    if (scc[a[i].x] ^ scc[a[i].y]) {
      addage(id[scc[a[i].x]], id[scc[a[i].y]]);
      addage(id[scc[a[i].y]], id[scc[a[i].x]]);
      ++du[id[scc[a[i].x]]];
      ++du[id[scc[a[i].y]]];
    }
  }
  for (register int i = 1; i <= top; i++)
    if (du[i] == 1) ans++;
  for (register int i = 1; i <= top; i++) {
    if (!vis[i] && !du[i]) sum++, ans++;
    if (!vis[i] && du[i]) {
      sum++;
      DFS1(i, 1);
      DFS2(res, 1, 0);
      ans += maxx - 2;
      res = 0;
      maxx = 0;
    }
  }
  printf("%d", n + sum - 1 - ans);
}
