#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg(x) cout << #x << " : " << x << endl
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define maxn 100005
vector<ll> edges[maxn];
ll dau[maxn];
ll n, m;
void dfs(ll source)
{
dau[source] = 1;
stack<ll> st;
st.push(source);
while (!st.empty())
{
ll p = st.top();
st.pop();
for (auto v : edges[p])
{
if (dau[v] == 1)
continue;
dau[v] = 1;
st.push(v);
}
}
}
int main()
{
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
cin >> n >> m;
for (ll i = 0; i < m; i++)
{
ll u, v;
cin >> u >> v;
u--, v--;
edges[u].push_back(v);
edges[v].push_back(u);
}
ll dem = 0;
for (ll i = 0; i < n; i++)
{
if (dau[i] == 0)
{
dem++;
dfs(i);
}
}
cout << dem << '\n';
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgZGJnKHgpIGNvdXQgPDwgI3ggPDwgIiA6ICIgPDwgeCA8PCBlbmRsCiNkZWZpbmUgcmVwKGksIGEsIGIpIGZvciAoaW50IGkgPSAoYSk7IGkgPD0gKGIpOyBpKyspCiNkZWZpbmUgbWF4biAxMDAwMDUKdmVjdG9yPGxsPiBlZGdlc1ttYXhuXTsKbGwgZGF1W21heG5dOwpsbCBuLCBtOwp2b2lkIGRmcyhsbCBzb3VyY2UpCnsKICAgIGRhdVtzb3VyY2VdID0gMTsKICAgIHN0YWNrPGxsPiBzdDsKICAgIHN0LnB1c2goc291cmNlKTsKICAgIHdoaWxlICghc3QuZW1wdHkoKSkKICAgIHsKICAgICAgICBsbCBwID0gc3QudG9wKCk7CiAgICAgICAgc3QucG9wKCk7CiAgICAgICAgZm9yIChhdXRvIHYgOiBlZGdlc1twXSkKICAgICAgICB7CiAgICAgICAgICAgIGlmIChkYXVbdl0gPT0gMSkKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICBkYXVbdl0gPSAxOwogICAgICAgICAgICBzdC5wdXNoKHYpOwogICAgICAgIH0KICAgIH0KfQppbnQgbWFpbigpCnsKICAgIC8vIGZyZW9wZW4oImlucHV0LnR4dCIsInIiLHN0ZGluKTsKICAgIC8vIGZyZW9wZW4oIm91dHB1dC50eHQiLCJ3IixzdGRvdXQpOwogICAgY2luID4+IG4gPj4gbTsKICAgIGZvciAobGwgaSA9IDA7IGkgPCBtOyBpKyspCiAgICB7CiAgICAgICAgbGwgdSwgdjsKICAgICAgICBjaW4gPj4gdSA+PiB2OwogICAgICAgIHUtLSwgdi0tOwogICAgICAgIGVkZ2VzW3VdLnB1c2hfYmFjayh2KTsKICAgICAgICBlZGdlc1t2XS5wdXNoX2JhY2sodSk7CiAgICB9CiAgICBsbCBkZW0gPSAwOwogICAgZm9yIChsbCBpID0gMDsgaSA8IG47IGkrKykKICAgIHsKICAgICAgICBpZiAoZGF1W2ldID09IDApCiAgICAgICAgewogICAgICAgICAgICBkZW0rKzsKICAgICAgICAgICAgZGZzKGkpOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgZGVtIDw8ICdcbic7CiAgICByZXR1cm4gMDsKfQ==