const int N = 1e5;
  
bool marked[N];
vector<int> c[N];
vector<int> topsort;

void dfs( int v ) {
  if (marked[v]) return;
  marked[v] = 1;
  for (int x : c[v]) dfs(x);
  topsort.push_back(v);
};

int main() {
  int cc = 0, n, m;
  cin >> n >> m;
  while (m--) {
    int a, b;
    cin >> a >> b, a--, b--; // 1..n
    c[a].push_back(b);
    c[b].push_back(a);
  }
  for (int i = 0; i < n; i++)
    if (!marked[i])
      cc++, dfs(i);
}