#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long xx = 0, flagg = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') {
    flagg = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    xx = xx * 10 + ch - '0';
    ch = getchar();
  }
  return xx * flagg;
}
void pus(long long xx, long long flagg) {
  if (xx < 0) {
    putchar('-');
    xx = -xx;
  }
  if (xx >= 10) pus(xx / 10, 0);
  putchar(xx % 10 + '0');
  if (flagg == 1) putchar(' ');
  if (flagg == 2) putchar('\n');
  return;
}
int n, m, i, x[200005], y[200005], sd[200005], zz[200005];
int tail, zhan[200005], sum, book[200005], ans, f[200005], max1;
int top, qu[400005], nex[400005], to[400005], fir[200005];
void lj(int u, int v, int w) {
  top++;
  nex[top] = fir[u];
  fir[u] = top;
  to[top] = v;
  qu[top] = w;
}
int zzz(int z) {
  if (zz[z] == z) return z;
  return zz[z] = zzz(zz[z]);
}
void ss(int u, int v, int w, int ww) {
  sd[v] = w;
  tail++;
  zhan[tail] = v;
  for (int top1 = fir[v]; top1; top1 = nex[top1])
    if (sd[to[top1]] == 0) {
      ss(v, to[top1], w + 1, qu[top1]);
    } else if (qu[top1] != ww && sd[to[top1]] < sd[v]) {
      while (zzz(zhan[tail]) != zzz(to[top1])) {
        zz[zzz(to[top1])] = zhan[tail];
        zhan[tail] = 0;
        tail--;
      }
    }
  if (zhan[tail] == v) {
    zhan[tail] = 0;
    tail--;
  }
}
void ss2(int u, int v) {
  book[v] = 1;
  if (sd[v] >= 2) sum++;
  f[v] = 1;
  for (int top1 = fir[v]; top1; top1 = nex[top1])
    if (to[top1] != u) {
      ss2(v, to[top1]);
      max1 = max(max1, f[v] + f[to[top1]]);
      f[v] = max(f[v], f[to[top1]] + 1);
    }
}
int main() {
  n = read();
  m = read();
  for (i = 1; i <= m; i++) {
    x[i] = read();
    y[i] = read();
    if (x[i] != y[i]) {
      lj(x[i], y[i], i);
      lj(y[i], x[i], i);
    } else {
      i--;
      m--;
    }
  }
  for (i = 1; i <= n; i++) zz[i] = i;
  for (i = 1; i <= n; i++)
    if (sd[i] == 0) ss(i, i, 1, 0);
  for (i = 1; i <= top; i++) {
    qu[i] = 0;
    to[i] = 0;
    nex[i] = 0;
  }
  for (i = 1; i <= n; i++) {
    fir[i] = 0;
    sd[i] = 0;
  }
  for (i = 1; i <= tail; i++) zhan[i] = 0;
  tail = 0;
  top = 0;
  for (i = 1; i <= m; i++)
    if (zzz(x[i]) != zzz(y[i])) {
      sd[zzz(x[i])]++;
      sd[zzz(y[i])]++;
      lj(zzz(x[i]), zzz(y[i]), 0);
      lj(zzz(y[i]), zzz(x[i]), 0);
    }
  for (i = 1; i <= n; i++)
    if (zzz(i) != i) ans++;
  ans--;
  for (i = 1; i <= n; i++)
    if (zzz(i) == i && book[i] == 0) {
      ans++;
      sum = 0;
      max1 = 1;
      ss2(i, i);
      sum -= max(max1 - 2, 0);
      ans += sum;
    }
  pus(ans, 2);
  return 0;
}
