#include <bits/stdc++.h>
using namespace std;
vector<int> c;
vector<int> vis;
vector<vector<int> > a;
void rec(int fr, int cur) {
  if (vis[cur] == 1) return;
  int i, to;
  vis[cur] = 1;
  for (i = 0; i < a[cur].size(); i++) {
    to = a[cur][i];
    if (to != fr && vis[to] == 1) {
      c[to] = 2;
    } else if (to != fr) {
      rec(cur, to);
      if (c[cur] == 2) {
        c[to] = 2;
      } else if (c[to] == 1 || c[to] == 2)
        c[cur] = 1;
      else
        c[to] = 1;
    }
  }
}
int main() {
  int n, i, j, m, x, y, ans = 0;
  cin >> n >> m;
  a.resize(n);
  c.assign(n, 0);
  vis.assign(n, 0);
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    a[x - 1].push_back(y - 1);
    a[y - 1].push_back(x - 1);
  }
  for (i = 0; i < n; i++) {
    rec(-1, i);
  }
  for (i = 0; i < n; i++) {
    if (c[i] == 0) ans++;
  }
  cout << ans;
}
