N, M = map(int,input().split())
t = [[] for _ in range(N)]
visited = [0] * N
for _ in range(M):
    X, Y, Z = map(int,input().split())
    X -= 1
    Y -= 1
    t[X].append(Y)
    t[Y].append(X)
ans = 0
for i in range(N):
    if visited[i]:
        continue
    ans += 1
    stack = [i]
    while stack:
        s = stack.pop()
        for to in t[s]:
            if visited[to]:
                continue
            visited[to] = 1
            stack.append(to)
print(ans) N, M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] t = [[] for _ in range(N)] t [[] for _ in range(N)] visited = [0] * N visited [0] * N [0] 0 N for _ in range(M):
    X, Y, Z = map(int,input().split())
    X -= 1
    Y -= 1
    t[X].append(Y)
    t[Y].append(X) _ range(M) range M X, Y, Z = map(int,input().split()) X map(int,input().split()) map int input().split() ().split () input split Y Z X -= 1 X 1 Y -= 1 Y 1 t[X].append(Y) [X].append [X] t X append Y t[Y].append(X) [Y].append [Y] t Y append X ans = 0 ans 0 for i in range(N):
    if visited[i]:
        continue
    ans += 1
    stack = [i]
    while stack:
        s = stack.pop()
        for to in t[s]:
            if visited[to]:
                continue
            visited[to] = 1
            stack.append(to) i range(N) range N if visited[i]:
        continue
     visited[i] visited i continue ans += 1 ans 1 stack = [i] stack [i] i while stack:
        s = stack.pop()
        for to in t[s]:
            if visited[to]:
                continue
            visited[to] = 1
            stack.append(to) stack s = stack.pop() s stack.pop() stack.pop stack pop for to in t[s]:
            if visited[to]:
                continue
            visited[to] = 1
            stack.append(to) to t[s] t s if visited[to]:
                continue
             visited[to] visited to continue visited[to] = 1 visited[to] visited to 1 stack.append(to) stack.append stack append to print(ans) print ans ans += 1 1 ans visited = [0] * N [0] * N visited Y -= 1 1 Y s = stack.pop() stack.pop() s X -= 1 1 X stack = [i] [i] stack t = [[] for _ in range(N)] [[] for _ in range(N)] t X, Y, Z = map(int,input().split()) map(int,input().split()) X ans = 0 0 ans Z = map(int,input().split()) map(int,input().split()) Z Y, Z = map(int,input().split()) map(int,input().split()) Y M = map(int,input().split()) map(int,input().split()) M N, M = map(int,input().split()) map(int,input().split()) N
N, M = map(int,input().split())
t = [[] for _ in range(N)]
visited = [0] * N
for _ in range(M):
    X, Y, Z = map(int,input().split())
    X -= 1
    Y -= 1
    t[X].append(Y)
    t[Y].append(X)
ans = 0
for i in range(N):
    if visited[i]:
        continue
    ans += 1
    stack = [i]
    while stack:
        s = stack.pop()
        for to in t[s]:
            if visited[to]:
                continue
            visited[to] = 1
            stack.append(to)
print(ans)