но у меня извиняйте ,как могу
Объяснение:
n,m=map(int,input().split())
tree=[]
count_tree=0
for i in range(m):
u,v = map(int,input().split())
not_in_tree = True
for tr in tree:
if u in tr:
if v not in tr:
tr.append(v)
count_tree +=1
not_in_tree=False
break
elif v in tr:
if u not in tr:
tr.append(u)
count_tree +=1
not_in_tree=False
break
if not_in_tree:
tree.append([u,v])
count_tree +=2
print(len(tree) + (n-count_tree))