#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using lli = long long int;
using iii = tuple<int, int, int>;
using iiii = tuple<int, int, int, int>;
using ulli = unsigned long long int;
using ui = unsigned int;
using Bit = bitset<30>;
const int maxBit = 30;
const int maxN = 3e5;
const int block = 600;
const int cBlocks = maxN / block;
const int C = 1e3;
const int maxM = 2e5;
const int maxl = 18;
const int inf = 0x3f3f3f3f;
const lli INF = 0x3f3f3f3f3f3f3f3f;
const char sp = ' ';
const char dl = '\n';
const int mod = 998244353;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int test = 1;
  while (test--) {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> Adj(n + 1);
    for (int i = 1, u, v; i <= m; i++) {
      cin >> u >> v;
      Adj[u].push_back(v);
      Adj[v].push_back(u);
    }
    vector<int> Mark(n + 1);
    vector<bool> Visited(n + 1);
    int res = 0;
    int Connected_component = 0;
    function<void(int)> DFS = [&](int u) {
      Mark[u] = Connected_component;
      Visited[u] = true;
      for (int v : Adj[u])
        if (!Visited[v]) DFS(v);
      return;
    };
    for (int i = 1; i <= n; i++)
      if (!Visited[i]) {
        Connected_component++;
        DFS(i);
      }
    vector<int> Sum_Vertex(Connected_component + 1),
        Sum_Edge(Connected_component + 1);
    for (int i = 1; i <= n; i++) {
      Sum_Vertex[Mark[i]]++;
      Sum_Edge[Mark[i]] += Adj[i].size();
    }
    for (int i = 1; i <= Connected_component; i++) {
      if (Sum_Edge[i] / 2 < Sum_Vertex[i]) res++;
    }
    cout << res;
  }
  return 0;
}
