#include <bits/stdc++.h>
using namespace std;
namespace custom {
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
template <class T>
void print(T a) {
  cout << a;
}
template <class T1, class T2>
void print(pair<T1, T2>& a) {
  cout << "{" << a.first << "," << a.second << "} ";
}
template <class T>
void parr(T& arr) {
  int i = 0;
  for (auto& el : arr) {
    if (i > 0) print(" ");
    print(el);
    i |= 1;
  }
}
template <class T>
void print(vector<T>& a) {
  parr(a);
}
template <class T>
void print(set<T>& a) {
  parr(a);
}
template <class T>
void print(queue<T>& a) {
  parr(a);
}
template <class T>
void print(deque<T>& a) {
  parr(a);
}
template <class T>
void print(stack<T>& a) {
  parr(a);
}
template <class T1, class T2>
void print(map<T1, T2>& a) {
  int i = 0;
  for (auto& el : a) {
    if (i > 0) print("\n");
    print(el.first);
    print(" : ");
    print(el.second);
    i |= 1;
  }
}
template <class arg1, class... args>
void print(arg1 f, args... n) {
  print(f);
  print(" ");
  print(n...);
}
template <class T>
void print(vector<vector<T>>& a) {
  for (auto& el : a) print(el, "\n");
}
template <class T>
int len(T& a) {
  return a.size();
}
template <class T>
long long sum(T& a) {
  long long s = 0;
  for (auto& el : a) s += el;
  return s;
}
}  // namespace custom
using namespace custom;
bool dfs(int p, int i, vector<int>& vis, vector<vector<int>>& ed) {
  if (vis[i]) {
    return true;
  }
  bool temp = false;
  vis[i] = 1;
  for (auto& el : ed[i]) {
    if (el == p) continue;
    temp |= (dfs(i, el, vis, ed));
  }
  return temp;
}
void solve() {
  int n, m;
  cin >> n >> m;
  int x, y;
  vector<vector<int>> ed(n + 1);
  for (int i = 0; i < m; i += 1) {
    cin >> x >> y;
    ed[x].push_back(y);
    ed[y].push_back(x);
  }
  vector<int> vis(n + 1, 0);
  int ans = 0;
  for (int i = 1; i < n + 1; i += 1) {
    if (vis[i]) continue;
    bool b = dfs(-1, i, vis, ed);
    if (!b) ans += 1;
  }
  print(ans);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
