#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> v;
const int MAXN = 100010;
bool vis[MAXN];
int deg[MAXN];
int left[MAXN];
void dfs(int node, int parent, bool is) {
  if (is) ++deg[node];
  if (vis[node]) return;
  vis[node] = true;
  for (int i = 0; i < v[node].size(); ++i) {
    if (v[node][i] != parent) dfs(v[node][i], node, true);
  }
}
int p1 = 0, p2 = 0;
void dfs2(int node) {
  if (vis[node]) return;
  vis[node] = true;
  if (deg[node] == 0)
    ++p1;
  else
    p2 += deg[node] - 1;
  for (int i = 0; i < v[node].size(); ++i) dfs2(v[node][i]);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  v.resize(n, vector<int>());
  for (int i = 0, a, b; i < m; ++i) {
    scanf("%d%d", &a, &b);
    --a;
    --b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  memset(vis, false, sizeof(vis));
  for (int i = 0; i < n; ++i)
    if (!vis[i]) dfs(i, -1, false);
  memset(vis, false, sizeof(vis));
  int tot = 0;
  for (int i = 0; i < n; ++i) {
    p1 = 0, p2 = 0;
    if (!vis[i])
      dfs2(i);
    else
      continue;
    p1 -= min(p2, p1);
    tot += p1;
  }
  printf("%d\n", tot);
  return 0;
}
