import networkx as X
n,m=map(int,input().split())
g=X.Graph()
for i in range(n):g.add_node(i+1)
for i in range(m):x,y,z=map(int,input().split());g.add_edge(x,y)
print(X.number_connected_components(g)) import networkx as X networkx n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m g=X.Graph() g X.Graph() X.Graph X Graph for i in range(n):g.add_node(i+1) i range(n) range n for i in range(m):x,y,z=map(int,input().split());g.add_edge(x,y) i range(m) range m print(X.number_connected_components(g)) print X.number_connected_components(g) X.number_connected_components X number_connected_components g g=X.Graph() X.Graph() g m=map(int,input().split()) map(int,input().split()) m n,m=map(int,input().split()) map(int,input().split()) n
import networkx as X
n,m=map(int,input().split())
g=X.Graph()
for i in range(n):g.add_node(i+1)
for i in range(m):x,y,z=map(int,input().split());g.add_edge(x,y)
print(X.number_connected_components(g))