Please log in to access this page.

Grandchild count

Added: 2026-03-25 07:08:23

Question Image

Grandchild count

Answer

✏️ Edit
n = int(input())
k = {}

for i in range(n):
    inp = input().split()
    if inp[1] not in k:
        k[inp[1]] = []
    k[inp[1]].append(inp[0])

p = input()
t = k[p]
print(len(k[t[0]]))