#include <bits/stdc++.h>
#pragma comment(linker, "/stack:64000000")
using namespace std;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
template <class T>
T jog(T a, T b) {
  return a + b;
}
template <class T>
T bog(T a, T b) {
  return a - b;
}
template <class T>
T gon(T a, T b) {
  return a * b;
}
template <class T>
T sq(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
template <class T>
T power(T a, T p) {
  T res = 1, x = a;
  while (p) {
    if (p & 1) res = res * x;
    x = x * x;
    p >>= 1;
  }
  return res;
}
template <class T>
T cordinatlenth(T a, T b, T c, T d) {
  return sqrt(sq(a - c) + sq(b - d));
}
template <class T>
string toString(T n) {
  ostringstream oss;
  oss << n;
  oss.flush();
  return oss.str();
}
int toInt(string s) {
  int r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
long long bigmod(long long a, long long p, long long mod) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    p >>= 1;
  }
  return res;
}
int diraction1[] = {-1, 0, 0, 1, 1, -1, -1, 1};
int diraction2[] = {0, -1, 1, 0, 1, -1, 1, -1};
int horsed1[] = {-2, -2, -1, 1, 2, 2, 1, -1};
int horsed2[] = {1, -1, -2, -2, -1, 1, 2, 2};
void Input();
const int INF = 2147483647;
const long long LINF = 9223372036854775807ll;
void DFs(int u);
int n, m, ans, fl, par[100010], nw[100010];
vector<vector<int> > graph;
bool mark[100010], ck[100010], mr[100010];
vector<int> vv;
int main() {
  Input();
  return 0;
}
void Input() {
  cin >> n >> m;
  graph.assign(n + 5, vector<int>());
  for (int i = 0, a, b; i < m; i++) {
    scanf("%d %d", &a, &b);
    graph[a].push_back(b);
    graph[b].push_back(a);
    ck[a] = ck[b] = true;
  }
  memset(par, -1, sizeof(par));
  memset(nw, 0, sizeof(nw));
  memset(mark, false, sizeof(mark));
  for (int i = 1; i <= n; i++) {
    if (!ck[i]) {
      ans++;
      continue;
    }
    if (mark[i]) continue;
    fl = 1;
    mr[i] = true;
    DFs(i);
    ans += fl;
  }
  cout << ans << endl;
}
void DFs(int u) {
  mark[u] = true;
  nw[u] = 1;
  for (int i = 0; i < graph[u].size(); i++) {
    int v = graph[u][i];
    if (par[u] != v && (nw[v] == 2 || nw[v] == 3)) fl = 0;
    if (mr[v] || par[u] == v || nw[v] >= 2) continue;
    par[v] = u;
    mr[v] = true;
    nw[u] = 2;
    DFs(v);
    par[v] = -1;
  }
  nw[u] = 3;
}
