qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
N, K = map(int,input().split())	
S = input()

#print(S[K-1])
S = (S[:K-2]+S[K-1].lower()+S[K:]
print(S)

# Fixed code:
N, K = map(int,input().split())	
S = input()

#print(S[K-1])
S = (S[:K-1] + S[K-1].lower() + S[K:])
print(S)
# Buggy code:
n, k = map(int, input().split())
s = input()

print(s[:k] + s[k].lower() + s[k+1:])

# Fixed code:
n, k = map(int, input().split())
s = input()

print(s[:k-1] + s[k-1].lower() + s[k:])
# Buggy code:
n,k = map(int,input().split())
s = list(input())
s[k-1] = s[k-1].lower()

print(s)

# Fixed code:
n, k = list(map(int, input().split()))
s = list(input())
s[k - 1] = s[k - 1].lower()
print("".join(s))
# Buggy code:
n, k = map(int, input().split())
s = input()
print(s[:k]+lower(s[k])+s[k+1:])


# Fixed code:
n, k = map(int, input().split())
s =input()
print(s[:k-1] + s[k-1].lower() +s[k:])
# Buggy code:
n,k=int(input().split())
s=input()
print(s[:k-1]+s.replace(s[k-1], s[k-1].lower())+s[k:])

# Fixed code:
n, k  = map(int, input().split())
s = input()
print(s[:k - 1] + s[k - 1].lower() + s[k:])
# Buggy code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
s = ns()

print(s[:k].lower() + s[k:])

# Fixed code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
s = ns()

print(s[:k-1] + s[k-1].lower() + s[k:])
# Buggy code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    n, k = [int(e) for e in input().split(" ")]
    print(n, k)
    s = ""
    for i, r in enumerate(input()):
        if i == k-1:
            s += r.lower()
        else:
            s += r
    print(s)

main()


# Fixed code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    n, k = [int(e) for e in input().split(" ")]
    s = ""
    for i, r in enumerate(input()):
        if i == k-1:
            s += r.lower()
        else:
            s += r
    print(s)

main()
# Buggy code:
n,k=map(int,input().split())
s=input()
print(s[0:k-1]+s[k-1]+s[k:])

# Fixed code:
n,k=map(int,input().split())
s=input()
print(s[0:k-1]+s[k-1].lower()+s[k:])
# Buggy code:
N, K = map(int, input().split())
s3 =[]

s = list(input())

s1 = s


s2= s1[K]

s3 = s2.lower()

s1[K] = s3

print('' .join(s1))


# Fixed code:
N, K = map(int, input().split())
s3 =[]

s = list(input())

s1 = s


s2= s1[K-1]

s3 = s2.lower()

s1[K-1] = s3

print('' .join(s1))
# Buggy code:
N,K=map(int,input().split())
S = list(input())

S[K-1] = S[K-1].lower()

print("".join(S)

# Fixed code:
N, K = map(int, input().split())
S = list(input())
tmp = S[K-1]
tmp = tmp.lower()
S[K-1] = tmp
print(''.join(S))
# Buggy code:
n, k = map(int, read().split())
s = read()
k -= 1
s= s[:k] + str.lower(s[k]) + s[k+1:]
print(s)

# Fixed code:
read = input
n, k = map(int, read().split())
s = read()
k -= 1
s= s[:k] + str.lower(s[k]) + s[k+1:]
print(s)
# Buggy code:
n,k=map(int,input().split())
s=input()
print(s[:k]+s[k-1].lower()+s[k+1:])

# Fixed code:
n,k=map(int, input().split())
S=input()
s=S.lower()
print(S[:k-1]+s[k-1]+S[k:])
# Buggy code:
 N,K= map(int, input().split())
 S = list(str(input()))

 S[K-1] = S[K-1].lower()
 print(''.join(S))

# Fixed code:
N, K  = list(map(int, input().split()))
S=list(input())
S[K - 1] = S[K - 1].lower()
print("".join(S))
# Buggy code:
n,k = map(int,input().split())
s = list(input())
s[k-1]= str.lower(s[k-1])
"".join(s)uu

# Fixed code:
n,k = map(int,input().split())
s = list(input())
s[k-1]= str.lower(s[k-1])
print("".join(s))
# Buggy code:
n, k = (int(i) for i in input().split())  
s = input()
s_ = s[:k-1] + s[k].lower() + s[k:]
print(s_)

# Fixed code:
n, k = [int(i)-1 for i in input().split()]
s = input()
print(s[:k]+s[k].lower()+s[k+1:])
# Buggy code:
N, K = map(int, input().split())
S = list(input())

S[K-1].lower()

ans = ''
ans = ''.join(S)

print(ans)

# Fixed code:
N, K = map(int, input().split())
S = list(input())

S[K-1] = S[K-1].lower()

S = ''.join(S)
print(S)
# Buggy code:
n,k=map(int,input().split())
s=input()
print(s[:k]+s[k].lower()+s[k+1:])

# Fixed code:
n,k=map(int,input().split())
s=input()
print(s[:(k-1)]+s[k-1].lower()+s[k:])
# Buggy code:
NK = input().split()
NK = [int(s) for s in NK]

S = input()

out = ''
if NK[1] == 1:
    out = S.capitalize().swapcase()
else:
    out = S[:NK[1] - 2] + S[NK[1]-1:].capitalize().swapcase()

print(out)

# Fixed code:
NK = input().split()
NK = [int(s) for s in NK]

S = input()

out = ''
if NK[1] == 1:
    out = S.capitalize().swapcase()
else:
    out = S[:NK[1] - 1] + S[NK[1]-1:].capitalize().swapcase()

print(out)
# Buggy code:
input1 = list(map(int, input().split()))

tar_str = input()

output_str = ''

for i in range(len(tar_str)):
    if i == input1[1]:
        output_str += tar_str[i].lower()
    else:
        output_str += tar_str[i]

print(output_str)


# Fixed code:
input1 = list(map(int, input().split()))

tar_str = input()

output_str = ''

for i in range(len(tar_str)):
    if i == input1[1] - 1:
        output_str += tar_str[i].lower()
    else:
        output_str += tar_str[i]

print(output_str)
# Buggy code:
n,k = map(int,input().splt())
s = list(input())
s[k-1] = s[k-1].lower()
s ="".join(s)
print(s)

# Fixed code:
n,k = map(int,input().split())
s = list(input())
s[k-1] = s[k-1].lower()
s ="".join(s)
print(s)
# Buggy code:
word_S = input().split(" ")[-1]
S = list(word_S)
change_K = int(input())
word1 = ""
for i in range(change_K - 1):
    word1 = word1 + S[i]
word2 = S[change_K - 1]
word3 = ""
count = 0
while True:
    try:
        word3 = word3 + S[change_K + count]
        count += 1
    except IndexError:
        break
word2 = word2.swapcase()
print(word1+word2+word3)


# Fixed code:
change_K = int(input().split(" ")[-1])
word_S = list(input())
S = list(word_S)
word1 = ""
for i in range(change_K - 1):
    word1 = word1 + S[i]
word2 = S[change_K - 1]
word3 = ""
count = 0
while True:
    try:
        word3 = word3 + S[change_K + count]
        count += 1
    except IndexError:
        break
word2 = word2.swapcase()
print(word1 + word2 + word3)
# Buggy code:
N, K = map(int, input().split())
S = input()
a = S[K-1]
S[K-1] = a.lower()
print(S)

# Fixed code:
N,K=map(int,input().split())
S=input()
a=S[K-1].lower()
print(S[:K-1]+a+S[K:])
# Buggy code:
n,k = map(int, input().split())
s = input()

s_temp = s.swapcase()

ans = s[:k]+s_temp[k]+s[k+1:]

print(ans)

# Fixed code:

n,k = map(int, input().split())
s = input()

s_temp = s.swapcase()

ans = s[:k-1]+s_temp[k-1]+s[k:]

print(ans)
# Buggy code:
n, k = list(map(int, input().split()))
s = input()
s[k - 1].lower()
print(s)

# Fixed code:
n, k = map(int, input().split())
s = list(input())

s[k-1] = s[k-1].lower()
print(''.join(s))
# Buggy code:
N, K = map(int, input().split())
s = list(input())
s[K-1] = s[K-1].lower()
print(s)

# Fixed code:
N, K = map(int, input().split())
s = list(input())
s[K-1] = s[K-1].lower()
print(''.join(s))
# Buggy code:
n,k=map(int,input().split())
s=list(input())
s[k-1]=s[k-1].lower()
print(s)


# Fixed code:
n, k = map(int, input().split())
s = list(input())
s[k-1] = s[k-1].lower()
print(''.join(s))
# Buggy code:
n, k = map(int, input().split())
s = input()

print(s[:k-1] + lower(s[k-1]) + s[k:])

# Fixed code:
n, k = map(int, input().split())
s = input()

k = k - 1
s = s[:k] + s[k].lower() + s[k+1:]
print(s)
# Buggy code:
N,K = map(int,input().split(" "))
S = input()

tmp = S[K-1].lower()
S[K-1] = tmp
ans = "".join(S)

print(ans)

# Fixed code:
N,K = map(int,input().split(" "))
S = list(input())

tmp = S[K-1].lower()
S[K-1] = tmp
ans = "".join(S)

print(ans)
# Buggy code:
n,k=map(int,input().split())
s=list(input())

s[k-1]=s[k-1].lower()

print(s)



# Fixed code:
n, k = map(int,input().split())
s = list(input())
s[k-1] = s[k-1].lower()
print(''.join(s))
# Buggy code:
class Unionfind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x

    def union(self, x, y):
        xp = self.find(x)
        yp = self.find(y)
        if xp != yp:
            if self.table[xp] <= self.table[yp]:
                self.table[yp] = xp
                self.table[xp] += self.table[yp]
            else:
                self.table[xp] = yp
                self.table[yp] += self.table[xp]

n, m = map(int, input().split())
clue = Unionfind(n)
for _ in range(m):
    x, y, _ = map(int, input().split())
    clue.union(x-1, y-1)
roots = set()
for i in range(n):
    roots.add(clue.find(i))
print(len(roots))

# Fixed code:
class Unionfind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x

    def union(self, x, y):
        xp = self.find(x)
        yp = self.find(y)
        if xp != yp:
            if self.table[xp] <= self.table[yp]:
                self.table[xp] += self.table[yp]
                self.table[yp] = xp
            else:
                self.table[yp] += self.table[xp]
                self.table[xp] = yp

n, m = map(int, input().split())
clue = Unionfind(n)
for _ in range(m):
    x, y, _ = map(int, input().split())
    clue.union(x-1, y-1)
roots = set()
for i in range(n):
    roots.add(clue.find(i))
print(len(roots))
# Buggy code:
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(s):
    if visited[s]:
        return
    visited[s] = 1
    for to in t[s]:
        if visited[to]:
            continue
        dfs(to)
    
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)
for i in range(1, N + 1):
    s = visited.index(0)
    dfs(s)
    if min(visited):
        ans = i
        break
print(ans)

# Fixed code:
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(s):
    if visited[s]:
        return
    visited[s] = 1
    for to in t[s]:
        if visited[to]:
            continue
        dfs(to)
    
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(0, N):
    if visited[i]:
        continue
    ans += 1
    dfs(i)
print(ans)
# Buggy code:
# coding: utf-8
# Your code here!
N,M = map(int,input().split())
lst = [i for i in range(N)]

def root(n):
    if n == lst[n]:
        return n
    lst[n] = func(lst[n])
    return lst[n]

def union(x,y)
    rootX, rootY = root(x), root(y)
    if rootX != rootY:
        lst[max(x,y)] = min(x,y)

for i in range(M):
    X,Y,Z = map(int,input().split())
    X -= 1
    Y -= 1
    union(X, Y)

for i in range(N):
    func(i)

ans = len([i for i in range(N) if lst[i] == i])
print(ans)



# Fixed code:
# coding: utf-8
# Your code here!
N,M = map(int,input().split())
lst = [i for i in range(N)]

def root(n):
    if n == lst[n]:
        return n
    lst[n] = root(lst[n])
    return lst[n]

def union(x,y):
    rootX, rootY = root(x), root(y)
    if rootX != rootY:
        if rootX > rootY:
            lst[rootX] = rootY
        if rootY > rootX:
            lst[rootY] = rootX

for i in range(M):
    X,Y,Z = map(int,input().split())
    X -= 1
    Y -= 1
    union(X, Y)

ans = len([i for i in range(N) if root(i) == i])
print(ans)
# Buggy code:
class UnionFind:
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n+1)
        self.cnt = 0

    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def groupsize(self):
        self.cnt = 0
        for i, x in enumerate(self.par):
            if x == i:
                self.cnt += 1
            return self.cnt
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

N, M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(M)]
uf = UnionFind(N)

for i in range(M):
    uf.union(A[i][0]-1, A[i][1]-1)

print(uf.groupsize())

# Fixed code:
class UnionFind:
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n+1)
        self.cnt = 0

    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def groupsize(self):
        self.cnt = 0
        for i, x in enumerate(self.par):
            if x == i:
                self.cnt += 1
        return self.cnt
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

N, M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(M)]
uf = UnionFind(N)

for i in range(M):
    uf.union(A[i][0]-1, A[i][1]-1)

print(uf.groupsize())
# Buggy code:
class UnionFind:
    def __init__(self,n):
        self.parent=[i for i in range(n)]
        self.rank=[0 for _ in range(n)]

    def find(self,x):
        if self.parent[x]==x:
            return x
        else:
            rootx=self.find(self.parent[x])
            self.parent[x]=rootx
            return rootx

    def union(self,x,y):
        rootx=self.find(x)
        rooty=self.find(y)
        if self.rank[rootx]<self.rank[rooty]:
            self.parent[rootx]=rooty
        else:
            self.parent[rooty]=rootx
            if self.rank[rootx]==self.rank[rooty]:
                self.rank[rootx]+=1

n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for _ in range(m)]
uf=UnionFind(n)
for x,y,z in xyz:
    x,y=x-1,y-1
    uf.union(x,y)

# print(uf.parent)
for i in range(n):
    uf.find(n)
print(len(set(uf.parent)))

# Fixed code:
class UnionFind:
    def __init__(self,n):
        self.parent=[i for i in range(n)]
        self.rank=[0 for _ in range(n)]

    def find(self,x):
        if self.parent[x]==x:
            return x
        else:
            rootx=self.find(self.parent[x])
            self.parent[x]=rootx
            return rootx

    def union(self,x,y):
        rootx=self.find(x)
        rooty=self.find(y)
        if self.rank[rootx]<self.rank[rooty]:
            self.parent[rootx]=rooty
        else:
            self.parent[rooty]=rootx
            if self.rank[rootx]==self.rank[rooty]:
                self.rank[rootx]+=1

n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for _ in range(m)]
uf=UnionFind(n)
for x,y,z in xyz:
    x,y=x-1,y-1
    uf.union(x,y)

# print(uf.parent)
for i in range(n):
    uf.find(i)
print(len(set(uf.parent)))
# Buggy code:
import sys
input = sys.stdin.readline

def main():
    n,m = map(int,input().split())
    li = [list(map(int,input().split())) for _ in range(m)]

    roots = [[] for _ in range(n)]
    for x,y,z in li:
        roots[x-1].append(y-1)
        roots[y-1].append(x-1)

    ans = 0
    count = 0
    stack = []
    group = [-1] * n

    while count < n:
        a = group.index(-1)
        stack.append(a)
        group[a] = ans
        count += 1
        while stack:
            label = stack.pop(-1)
            for i in roots[label]:
                if group[i] == -1:
                    group[i] = ans
                    stack.append(i)
                    count += 1
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()


# Fixed code:
import sys
input = sys.stdin.readline

def main():
    n,m = map(int,input().split())
    li = [list(map(int,input().split())) for _ in range(m)]

    roots = [[] for _ in range(n)]
    for x,y,z in li:
        roots[x-1].append(y-1)
        roots[y-1].append(x-1)

    ans = 0
    count = 0
    group = [-1] * n

    for i in range(n):
        if group[i] == -1:
            stack = [i]
            while stack:
                label = stack.pop(-1)
                for j in roots[label]:
                    if group[j] == -1:
                        group[j] = ans
                        stack.append(j)
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()
# Buggy code:
import sys
sys.setrecursionlimit(100000)

def visit_tree(now, num):
    visited[now] = num
    for i in range(len(tree[now])):
        if not visited[now]:
            visit_tree(tree[now][i], num)

n, m = map(int, input().split())
tree = [[] for _ in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    tree[x - 1].append(y - 1)
    tree[y - 1].append(x - 1)

visited = [0 for _ in range(n)]
num = 0
for i in range(n):
    if not visited[i]:
        num += 1
        visit_tree(i, num)

print(num)

# Fixed code:
import sys
sys.setrecursionlimit(10000000)

def visit_tree(now, num):
    visited[now] = num
    for i in range(len(tree[now])):
        if not visited[tree[now][i]]:
            visit_tree(tree[now][i], num)

n, m = map(int, input().split())
tree = [[] for _ in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    tree[x - 1].append(y - 1)
    tree[y - 1].append(x - 1)

visited = [0 for _ in range(n)]
num = 0
for i in range(n):
    if not visited[i]:
        num += 1
        visit_tree(i, num)

print(num)
# Buggy code:
import sys
inputs = sys.stdin.readline
N, M = map(int,inputs().split())
K = [None]*M
for t in range(M):
	x, y, z = map(int,inputs().split())
	K[t] = (x, y)
c = 0

U = [0]*(N+1)

for k in K:
	if U[k[0]] and U[k[1]]:
		a = U[k[0]]
		while(U[a] != a ):
			a = U[a]
		U[k[1]] = a
	elif U[k[1]]:
		U[k[0]] = U[k[1]]
	elif U[k[0]]:
		U[k[1]] = U[k[0]]
	else:
		U[k[0]] = k[0]
		U[k[1]] = k[0]

ans = 0
group = set()
for u in U[1:]:
	if u == 0:
		ans += 1
		continue
	elif u == U[u]:
		ans += 1
		group.add(u)
	elif u in group:
		group.add(u)
		continue
	else:
		while(u != U[u] and u not in group):
			group.add(u)
		group.add(u)
print(ans)

# Fixed code:
import sys
inputs = sys.stdin.readline
N, M = map(int,inputs().split())
K = [None]*M
for t in range(M):
	x, y, z = map(int,inputs().split())
	K[t] = (x, y)
c = 0

U = [0]*(N+1)

for k in K:
	if U[k[0]] and U[k[1]]:
		a = U[k[0]]
		b = U[k[1]]
		while(U[a] != a ):
			a = U[a]
		while(U[b] != b ):
			c = b
			b = U[b]
			U[c] = a
		U[b] = a
	elif U[k[1]]:
		U[k[0]] = U[k[1]]
	elif U[k[0]]:
		U[k[1]] = U[k[0]]
	else:
		U[k[0]] = k[0]
		U[k[1]] = k[0]

ans = 0
c = 0
group = set()
for n in range(1,N+1):
	if U[n] == 0:
		ans += 1
		continue
	elif n == U[n]:
		ans += 1
		group.add(U[n])
	elif U[n] in group:
		continue
	else:
		while(n != U[n] and U[n] not in group):
			group.add(U[n])
			n = U[n]
		group.add(U[n])
print(ans)
# Buggy code:
N,M=map(int,input().split())
root=[-1]*N
def search(i):
    if root[i]>=0:
        root[i]=search(root[i])
        return root[i]
    return i
for i in range(M):
    x,y,z=map(int,input().split())
    x-=1
    y-=1
    rx=search(x)
    ry=search(y)
    if rx==ry:
        continue
    elif root[rx]<=root[ry]:
        root[ry]+=root[rx]
        root[rx]=ry
    else:
        root[rx]+=root[ry]
        root[ry]=rx
ans=0
print(root)
for i in range(N):
    if root[i]<0:
        ans+=1
print(ans)

# Fixed code:
N,M=map(int,input().split())
root=[-1]*N
def search(i):
    if root[i]>=0:
        root[i]=search(root[i])
        return root[i]
    return i
for i in range(M):
    x,y,z=map(int,input().split())
    x-=1
    y-=1
    rx=search(x)
    ry=search(y)
    if rx==ry:
        continue
    elif root[rx]<=root[ry]:
        root[ry]+=root[rx]
        root[rx]=ry
    else:
        root[rx]+=root[ry]
        root[ry]=rx
ans=0
for i in range(N):
    if root[i]<0:
        ans+=1
print(ans)
# Buggy code:
n, m = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
  u,v,z=map(int, input().split())
  g[u-1].append((u-1, v-1, z))
  g[v-1].append((v-1,u-1,z))
count = 0
renketu_list = [-1]*n
stack = []
for i in range(n):
  if renketu_list[i] == -1:
    count += 1
    renketu_list[i] = count
    while len(g[i]) > 0:
      stack.append(g[i].pop())
    while len(stack) > 0:
      u,v,z=stack.pop()
      if renketu_list == -1:
        renketu_list[v] = count
        while len(g[v])>0:
          stack.append(g[v].pop())

print(count)

# Fixed code:
n, m = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
  u,v,z=map(int, input().split())
  g[u-1].append((u-1, v-1, z))
  g[v-1].append((v-1,u-1,z))
count = 0
renketu_list = [-1]*n
stack = []
for i in range(n):
  if renketu_list[i] == -1:
    count += 1
    renketu_list[i] = count
    while len(g[i]) > 0:
      stack.append(g[i].pop())
    while len(stack) > 0:
      u,v,z=stack.pop()
      if renketu_list[v] == -1:
        renketu_list[v] = count
        while len(g[v])>0:
          stack.append(g[v].pop())

print(count)
# Buggy code:
class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
    def find(self, x):
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parent[x] = y

def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for i in range(M):
        X, Y, Z = map(int, input().split())
        uf.union(X-1, Y-1)
    s = set()
    for i in range(N):
        s.add(uf.find(i))
    print(len(s))

if __name__ == "__main__":
    sys.setrecursionlimit(10**6)
    main()


# Fixed code:
import sys

class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
    def find(self, x):
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parent[x] = y

def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for i in range(M):
        X, Y, Z = map(int, input().split())
        uf.union(X-1, Y-1)
    s = set()
    for i in range(N):
        s.add(uf.find(i))
    print(len(s))

if __name__ == "__main__":
    sys.setrecursionlimit(10**6)
    main()
# Buggy code:
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, M = map(int,input().split())
q = []
c = [0] * N
A = [[] for i in range(N)]

for i in range(M):
	x, y, z = map(int,input().split())
	x = x - 1
	y = y - 1
	#A[x].append(y)
	A[y].append(x)

cost = 0
for i in range(N):
	if c[i] == 0:
		cost = cost + 1
		q.append(i)
		while len(q):
			j = q.pop(0)
			c[j] = 1
			for k in A[j]:
				if c[k] == 0:
					q.append(k)

print(cost)


# Fixed code:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, M = map(int,input().split())
q = []
c = [0] * N
A = [[] for i in range(N)]

for i in range(M):
	x, y, z = map(int,input().split())
	x = x - 1
	y = y - 1
	A[x].append(y)
	A[y].append(x)

cost = 0
for i in range(N):
	if c[i] == 0:
		cost += 1
		q.append(i)
		while len(q):
			j = q.pop()
			c[j] = 1
			for k in A[j]:
				if c[k] == 0:
					q.append(k)

print(cost)