#include <bits/stdc++.h>
using namespace std;
bool vis[1000000];
int pai[1000000], peso[1000000];
bool iscly = false;
vector<int> adj[1000000];
void dfs(int u, int v) {
  vis[u] = true;
  for (int i = 0; i < adj[u].size(); i++) {
    int k = adj[u][i];
    if (k != v) {
      if (vis[k])
        iscly = true;
      else {
        dfs(k, u);
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    vis[i] = false;
    adj[i].clear();
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  long long int s = 0;
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      iscly = false;
      dfs(i, i);
      iscly ? s += 0 : s += 1;
    }
  }
  cout << s;
  cout << endl;
}
