#include <bits/stdc++.h>
bool visited[100001];
using namespace std;
class Graph {
  int V;

 public:
  Graph(int V);
  void addEdge(int v, int w);
  bool isCyclicUtil(int v, bool visited[], int parent);
  list<int> *adj;
};
Graph::Graph(int V) {
  this->V = V;
  adj = new list<int>[V];
}
void Graph::addEdge(int v, int w) {
  adj[v].push_back(w);
  adj[w].push_back(v);
}
bool Graph::isCyclicUtil(int v, bool visited[], int parent) {
  visited[v] = true;
  list<int>::iterator i;
  for (i = adj[v].begin(); i != adj[v].end(); ++i) {
    if (!visited[*i]) {
      if (isCyclicUtil(*i, visited, v)) return true;
    } else if (*i != parent)
      return true;
  }
  return false;
}
int main() {
  memset(visited, 0, false);
  int n, m, x, y, ans = 0, i;
  cin >> n >> m;
  Graph g(n);
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    g.addEdge(x, y);
  }
  for (i = 0; i < n; i++) {
    if (!visited[i]) {
      if (!g.isCyclicUtil(i, visited, -1))
        ans++;
      else if (g.adj[i].size() == 0)
        ans++;
    }
  }
  cout << ans;
  return 0;
}
