The Resistance is trying to take control over all planets in a particular solar system. This solar system is shaped like a tree. More precisely, some planets are connected by bidirectional hyperspace tunnels in such a way that there is a path between every pair of the planets, but removing any tunnel would disconnect some of them.

The Resistance already has measures in place that will, when the time is right, enable them to control every planet that is not remote. A planet is considered to be remote if it is connected to the rest of the planets only via a single hyperspace tunnel.

How much work is there left to be done: that is, how many remote planets are there?


-----Input-----

The first line of the input contains an integer N (2 ≤ N ≤ 1000) – the number of planets in the galaxy.

The next N - 1 lines describe the hyperspace tunnels between the planets. Each of the N - 1 lines contains two space-separated integers u and v (1 ≤ u, v ≤ N) indicating that there is a bidirectional hyperspace tunnel between the planets u and v. It is guaranteed that every two planets are connected by a path of tunnels, and that each tunnel connects a different pair of planets.


-----Output-----

A single integer denoting the number of remote planets.


-----Examples-----
Input
5
4 1
4 2
1 3
1 5

Output
3

Input
4
1 2
4 3
1 4

Output
2



-----Note-----

In the first example, only planets 2, 3 and 5 are connected by a single tunnel.

In the second example, the remote planets are 2 and 3.

Note that this problem has only two versions – easy and medium.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
n = int(input())
tree = [0] * (n + 1)
for i in range(n - 1):
	(vex1, vex2) = list(map(int, input().split()))
	tree[vex1] += 1
	tree[vex2] += 1
ans = 0
for i in range(n + 1):
	if tree[i] == 1:
		ans += 1
print(ans)


n = int(input())
lst = []
for x in range(n - 1):
	(a, b) = input().split()
	lst.append(a)
	lst.append(b)
cnt = 0
for bruh in lst:
	if lst.count(bruh) == 1:
		cnt += 1
print(cnt)


n = int(input())
c = {}
for i in range(n - 1):
	t = list(map(int, input().split()))
	try:
		c[t[0]] += 1
		if c[t[0]] == 1:
			c.pop(t[0])
	except:
		c[t[0]] = 1
	try:
		c[t[1]] += 1
		if c[t[1]] == 1:
			c.pop(t[0])
	except:
		c[t[1]] = 1
t = 0
for i in c:
	if c[i] == 1:
		t += 1
print(t)


N = int(input())
M = []
r = 0
for k in range(N):
	M.append(0)
for k in range(N - 1):
	(a, b) = input().split()
	M[int(a) - 1] += 1
	M[int(b) - 1] += 1
for k in range(N):
	if M[k] == 1:
		r += 1
print(r)


n = int(input())
l = []
while n != 1:
	(a, m) = map(int, input().split())
	l.append(a)
	l.append(m)
	n -= 1
c = 0
for i in range(len(l)):
	if l.count(l[i]) <= 1:
		c += 1
print(c)


n = int(input())
k = []
z = 0
for i in range(n - 1):
	(a, b) = map(int, input().split())
	k.append(a)
	k.append(b)
for i in range(1, n + 1):
	if k.count(i) <= 1:
		z += 1
print(z)


def fun(ls):
	dct = {}
	count = 0
	for i in ls:
		(f, s) = i
		if f in dct:
			dct[f] = dct.get(f) + 1
		else:
			dct[f] = 1
		if s in dct:
			dct[s] = dct.get(s) + 1
		else:
			dct[s] = 1
	for (key, value) in dct.items():
		if value < 2:
			count += 1
	print(count)
T = int(input())
ls = []
for i in range(T - 1):
	lt = list(map(int, input().split()))
	ls.append(lt)
fun(ls)


import sys
from collections import Counter

def main(args):
	n = int(input())
	counter = Counter()
	for _ in range(n - 1):
		(u, v) = map(int, input().split())
		counter[u] += 1
		counter[v] += 1
	s = 0
	for c in range(n + 1):
		s += counter[c] == 1
	print(s)
sys.exit(main(sys.argv))


n = int(input())
myList = []
for k in range(0, n):
	myList.append(0)
counter = 0
for i in range(0, n - 1):
	(a, b) = map(int, input().split())
	myList[a - 1] += 1
	myList[b - 1] += 1
for j in range(0, len(myList)):
	if myList[j] == 1:
		counter += 1
print(counter)


t = int(input())
dic1 = {}
dic2 = {}
remotes = [False] * t
for i in range(t - 1):
	(a, b) = input().split()
	k = dic1.get(a, -1)
	if k == -1:
		dic1[a] = list()
	dic1[a].extend([b])
	k = dic2.get(b, -1)
	if k == -1:
		dic2[b] = list()
	dic2[b].extend([a])
for i in range(1, t + 1):
	res = 0
	if str(i) in dic1:
		if len(dic1[str(i)]) > 1:
			res = 1
		elif str(i) in dic2 and len(dic1[str(i)]) + len(dic2[str(i)]) > 1:
			res = 1
	if str(i) in dic2:
		if len(dic2[str(i)]) > 1:
			res = 1
		elif str(i) in dic1 and len(dic1[str(i)]) + len(dic2[str(i)]) > 1:
			res = 1
	remotes[i - 1] = res
print(remotes.count(0))


n = int(input())
counterArray = [0] * n
for _ in range(n - 1):
	(s, g) = map(int, input().split())
	counterArray[s - 1] += 1
	counterArray[g - 1] += 1
res = 0
for i in counterArray:
	if i == 1:
		res += 1
print(res)


from collections import Counter
n = int(input())
C = Counter()
for _ in range(n - 1):
	C.update(map(int, input().split()))
print(sum((1 for (a, b) in C.items() if b == 1)))


n = int(input())
d = {}
for i in range(1, n):
	(x, y) = map(int, input().split())
	if x in d:
		d[x].append(y)
	else:
		d[x] = [y]
	if y in d:
		d[y].append(x)
	else:
		d[y] = [x]
c = 0
for i in d:
	if len(d[i]) == 1:
		c += 1
print(c)


n = int(input())
cons = []
for i in range(n - 1):
	cons += [int(x) for x in input().split()]
cnt = 0
for i in range(1, n + 1):
	if cons.count(i) == 1:
		cnt += 1
print(cnt)


occur = set()
remove = set()

def cek(x):
	global occur, remove
	if x in occur:
		remove.add(x)
	else:
		occur.add(x)
for _ in range(int(input()) - 1):
	(a, b) = map(int, input().split())
	cek(a)
	cek(b)
print(len(occur - remove))


n = int(input())
li = [0] * n
for x in range(0, n - 1):
	line = input().split()
	for x in line:
		li[int(x) - 1] += 1
print(li.count(1))


P = lambda : map(int, input().split())
N = lambda : int(input())
n = N()
a = [0] * n
while n > 1:
	(u, v) = P()
	a[u - 1] += 1
	a[v - 1] += 1
	n -= 1
print(len([i for i in range(len(a)) if a[i] < 2]))


from collections import defaultdict
d = defaultdict(int)
for _ in range(int(input()) - 1):
	(u, v) = input().split()
	d[u] += 1
	d[v] += 1
print(sum((n == 1 for n in d.values())))


N = int(input())
pairs = [tuple(map(int, input().split())) for i in range(N - 1)]
graph = {i: list() for i in range(1, N + 1)}
for el in pairs:
	(x, y) = el
	graph[x].append(y)
	graph[y].append(x)
print(sum((1 for i in range(1, N + 1) if len(graph[i]) == 1)))


N = int(input())
Check = [0] * N
for i in range(N - 1):
	X = list(map(int, input().split()))
	(Check[X[0] - 1], Check[X[1] - 1]) = (Check[X[0] - 1] + 1, Check[X[1] - 1] + 1)
print(Check.count(1))


from collections import Counter
N = int(input())
count = [0] * N
for i in range(N - 1):
	(a, b) = input().split()
	count[int(a) - 1] += 1
	count[int(b) - 1] += 1
count2 = 0
for i in range(N):
	if count[i] < 2:
		count2 += 1
print(count2)


n = int(input())
counter = 0
a = [[0 for j in range(n)] for i in range(n)]
for i in range(n - 1):
	(i, j) = map(int, input().split())
	a[i - 1][j - 1] = 1
	a[j - 1][i - 1] = 1
for element in a:
	if element.count(1) == 1:
		counter += 1
print(counter)


n = int(input())
arr = []
for i in range(0, n - 1):
	li = list(map(int, input().split()))
	u = li[0]
	v = li[1]
	arr.append(u)
	arr.append(v)
cnt = 0
for i in arr:
	if arr.count(i) == 1:
		cnt += 1
print(cnt)


p = int(input())
a = []
x = 0
for i in range(p - 1):
	a += input().split()
for i in range(p):
	if a.count(str(i + 1)) == 1:
		x += 1
print(x)


n = int(input())
m = [0 for i in range(n)]
for i in range(n - 1):
	(u, v) = map(int, input().split())
	m[u - 1] += 1
	m[v - 1] += 1
print(m.count(1))


n = int(input())
d = {}
for i in range(n - 1):
	(x, y) = map(int, input().split())
	if x in d:
		d[x] += 1
	else:
		d[x] = 1
	if y in d:
		d[y] += 1
	else:
		d[y] = 1
ans = 0
for i in d.keys():
	if d[i] == 1:
		ans += 1
print(ans)


n = int(input())
(a, d, f) = ([], 0, 0)
for i in range(n - 1):
	(k, l) = list(map(int, input().split()))
	a.append(k)
	a.append(l)
for i in range(len(a)):
	d = 0
	for j in range(len(a)):
		if i != j and a[i] == a[j]:
			d = d + 1
	if d == 0:
		f = f + 1
print(f)


n = int(input())
lst = []
p = []
for i in range(n - 1):
	lst.append(list(map(int, input().split())))
	p.append(lst[i][0])
	p.append(lst[i][1])
count = 0
for i in range(len(p)):
	if p.count(p[i]) == 1:
		count += 1
print(count)


n = int(input())
a = set()
b = set()
for _ in range(n - 1):
	(c1, c2) = map(int, input().split())
	for c in [c1, c2]:
		if c in b:
			pass
		elif c in a:
			b.add(c)
			a.remove(c)
		else:
			a.add(c)
print(len(a))


n = []
a = 0
for _ in range(int(input()) - 1):
	s = list(map(int, input().split()))
	for x in s:
		n.append(x)
for x in n:
	if n.count(x) == 1:
		a += 1
print(a)


n = int(input())
tun = {}
for i in range(n):
	tun[i + 1] = 0
for i in range(n - 1):
	(u, v) = map(int, input().split())
	tun[u] += 1
	tun[v] += 1
ans = 0
for i in range(1, n + 1):
	if tun[i] == 1:
		ans += 1
print(ans)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x) + '\n')
n = get_int()
d = {}
for i in range(1, n + 1):
	d[i] = 0
for i in range(n - 1):
	(a, b) = get_int_list()
	d[a] += 1
	d[b] += 1
count = 0
for (i, v) in d.items():
	if v == 1:
		count += 1
print(count)


import sys, bisect
n = int(sys.stdin.readline())
deg = [0] * (n + 1)
for _ in range(n - 1):
	(a, b) = map(int, sys.stdin.readline().split())
	deg[a] += 1
	deg[b] += 1
ans = 0
for i in deg:
	if i == 1:
		ans += 1
print(ans)


n = int(input())
arr = []
for _ in range(n):
	arr.append(0)
for _ in range(n - 1):
	(a, b) = list(map(int, input().split()))
	arr[a - 1] += 1
	arr[b - 1] += 1
print(arr.count(1))


cnt = {}
for _ in range(int(input()) - 1):
	(a, b) = map(int, input().split())
	if a not in cnt:
		cnt[a] = 1
	else:
		cnt[a] += 1
	if b not in cnt:
		cnt[b] = 1
	else:
		cnt[b] += 1
count = 0
for (k, v) in cnt.items():
	if v == 1:
		count += 1
print(count)


n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n - 1):
	(u, v) = [int(r) - 1 for r in input().split()]
	graph[u].append(v)
	graph[v].append(u)
ans = 0
for adj in graph:
	if len(adj) == 1:
		ans += 1
print(ans)


n = int(input())
d = [0] * (n + 1)
for _ in range(n - 1):
	(x, y) = map(int, input().split())
	d[x] += 1
	d[y] += 1
print(d.count(1))


N = int(input())
a = [0 for i in range(N)]
for i in range(N - 1):
	(u, v) = map(int, input().split())
	a[u - 1] += 1
	a[v - 1] += 1
count = 0
for j in range(N):
	if a[j] == 1:
		count += 1
print(count)


from collections import defaultdict
n = int(input())
d = defaultdict(list)
for i in range(n - 1):
	(a, b) = map(int, input().split())
	d[a].append(b)
	d[b].append(a)
t = 0
for i in d:
	if len(d[i]) == 1:
		t = t + 1
print(t)


n = int(input())
lista = []
listb = []
for i in range(n - 1):
	(a, b) = map(int, input().split())
	lista.append(a)
	listb.append(b)
listf = []
seta = set(lista)
setb = set(listb)
for i in seta:
	if lista.count(i) == 1 and listb.count(i) == 0:
		listf.append(i)
for j in setb:
	if j not in listf:
		if listb.count(j) == 1 and lista.count(j) == 0:
			listf.append(j)
print(len(listf))


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	l = [[] for _ in range(n)]
	for _ in range(n - 1):
		(a, b) = LI()
		a -= 1
		b -= 1
		l[a].append(b)
		l[b].append(a)
	ans = 0
	for x in l:
		if len(x) == 1:
			ans += 1
	return ans
print(main())


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = 1
if debug:
	test_count = inp()
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	n = inp()
	counts = [0] * (n + 1)
	for i in range(n - 1):
		(a, b) = invr()
		counts[a] += 1
		counts[b] += 1
	ans = 0
	for i in range(1, n + 1):
		if counts[i] <= 1:
			ans += 1
	print(ans)


n = int(input())
a = [0] * (n + 1)
for i in range(n - 1):
	(u, v) = list(map(int, input().split()))
	a[u] += 1
	a[v] += 1
cnt = 0
for i in range(1, n + 1):
	if a[i] == 1:
		cnt += 1
print(cnt)


from sys import stdin, stdout
from math import ceil
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007

def solve():
	n = inp()
	ans = 0
	d = {}
	for i in range(n - 1):
		(a, b) = mp()
		d[a] = d.get(a, []) + [b]
		d[b] = d.get(b, []) + [a]
	for i in d:
		if len(d[i]) == 1:
			ans += 1
	pr(ans)
for _ in range(1):
	solve()


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect

def solve():
	n = scanner()
	vis = {}
	for i in range(n - 1):
		(u, v) = read()
		d = vis.get(u, 0)
		vis[u] = d + 1
		d = vis.get(v, 0)
		vis[v] = d + 1
	c = 0
	for x in vis.values():
		if x == 1:
			c += 1
	print(c)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(1):
	solve()


__author__ = 'Esfandiar'
n = int(input())
g = [[] for i in range(n)]
for i in range(n - 1):
	(u, v) = map(int, input().split())
	g[u - 1].append(v - 1)
	g[v - 1].append(u - 1)
print(sum([len(g[i]) == 1 for i in range(n)]))


n = int(input())
count = {}
for _ in range(n - 1):
	(u, v) = map(int, input().split())
	count[u] = count.get(u, 0) + 1
	count[v] = count.get(v, 0) + 1
ans = sum([1 for x in count.values() if x == 1])
print(ans)


from collections import Counter
n = int(input())
s = {}
for i in range(n - 1):
	(u, v) = map(int, input().strip().split())
	s[u] = s.get(u, 0) + 1
	s[v] = s.get(v, 0) + 1
print(Counter(s.values())[1])


n = int(input())
ref = n * [0]
for j in range(n - 1):
	(a, b) = [int(j) for j in input().split()]
	ref[a - 1] += 1
	ref[b - 1] += 1
count = 0
for j in range(n):
	if ref[j] == 1:
		count += 1
print(count)


N = int(input())
cnt = [0] * N
for n in range(N - 1):
	(u, v) = map(int, input().split())
	cnt[u - 1] += 1
	cnt[v - 1] += 1
print(sum((x == 1 for x in cnt)))


def main_function():
	n = int(input())
	hash = [0 for i in range(n + 1)]
	for i in range(n - 1):
		(a, b) = [int(i) for i in input().split(' ')]
		hash[a] += 1
		hash[b] += 1
	counter = 0
	for i in hash:
		if i == 1:
			counter += 1
	print(counter)
main_function()


n = int(input())
ls = []
for i in range(n - 1):
	(p, q) = map(int, input().split())
	ls.append(p)
	ls.append(q)
s = 0
for i in ls:
	if ls.count(i) == 1:
		s += 1
print(s)


t = int(input())
li = []
count = 0
for i in range(t - 1):
	(l, r) = map(int, input().split())
	li.append(r)
	li.append(l)
for i in li:
	if li.count(i) == 1:
		count += 1
print(count)


n = int(input()) - 1
a = ''
for i in range(n):
	uv = input().split()
	u = int(uv[0])
	v = int(uv[1])
	a += str(u) + ' ' + str(v) + ' '
a = sorted([int(i) for i in a.split()])
i = 0
k = 0
for i in range(2 * n):
	if i == 0 and a[0] != a[1]:
		k += 1
	elif i == 2 * n - 1 and a[2 * n - 2] != a[2 * n - 1]:
		k += 1
	elif 0 < i < 2 * n - 1 and a[i] != a[i - 1] and (a[i] != a[i + 1]):
		k += 1
print(k)


arr = []
ans = 0
n = int(input())
for i in range(n - 1):
	(a, b) = map(int, input().split())
	arr.append(a)
	arr.append(b)
test = [i for i in range(1, n + 1)]
for i in test:
	if arr.count(i) <= 1:
		ans = ans + 1
print(ans)


t = []
for k in range(int(input()) - 1):
	(a, b) = map(int, input().split())
	t.append(a)
	t.append(b)
y = set(t)
p = 0
for i in y:
	if t.count(i) == 1:
		p += 1
print(p)


from collections import Counter
import io
import os
import sys
from atexit import register
import random
import math
import itertools
DEBUG = False
STRESSTEST = False
if not DEBUG:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
sys.stdout = io.BytesIO()
register(lambda : os.write(1, sys.stdout.getvalue()))
tokens = []
tokens_next = 0

def nextStr():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = input().split()
		tokens_next = 0
	tokens_next += 1
	if type(tokens[tokens_next - 1]) == str:
		return tokens[tokens_next - 1]
	return tokens[tokens_next - 1].decode()

def nextInt():
	return int(nextStr())

def nextIntArr(n):
	return [nextInt() for i in range(n)]

def print(*argv, end='\n'):
	for arg in argv:
		sys.stdout.write((str(arg) + ' ').encode())
	sys.stdout.write(end.encode())

def genTestCase():
	raise NotImplementedError

def bruteforce(a):
	raise NotImplementedError

def doStressTest():
	while True:
		curTest = genTestCase()
		mySoln = solve(curTest)
		bruteforceSoln = bruteforce(curTest)
		if mySoln != bruteforceSoln:
			print('### Found case ###')
			print(curTest)
			print(f'{mySoln} should have been: {bruteforceSoln}')
			return

def solve(edges):
	c = Counter()
	for e in edges:
		for i in e:
			c[i] += 1
	return sum((1 for i in c if c[i] == 1))
if not DEBUG and STRESSTEST:
	raise Exception('Wrong flags!')
if STRESSTEST:
	doStressTest()
else:
	n = nextInt()
	a = []
	for _ in range(n - 1):
		a.append((nextInt(), nextInt()))
	res = solve(a)
	print(res)
sys.stdout.flush()


a = []
for s in [*open(0)][1:]:
	a += [*map(int, s.split())]
print(sum((a.count(x) == 1 for x in range(1, len(a) + 2))))


N = int(input())
src = [tuple([int(x) - 1 for x in input().split()]) for i in range(N - 1)]
es = [[] for i in range(N)]
for (a, b) in src:
	es[a].append(b)
	es[b].append(a)
ans = 0
for e in es:
	if len(e) == 1:
		ans += 1
print(ans)


n = int(input())
graph = {i: [] for i in range(1, n + 1)}
for _ in range(n - 1):
	(a, b) = map(int, input().split())
	graph[a].append(b)
	graph[b].append(a)
r = 0
for i in range(1, n + 1):
	r += len(graph[i]) == 1
print(r)


n = int(input())
l = [2 for i in range(n)]
for i in range(n - 1):
	(u, v) = map(int, input().split())
	l[u - 1] -= 1
	l[v - 1] -= 1
print(l.count(1))


TN = 1

def solution():
	n = int(input())
	l = [[0 for j in range(n)] for i in range(n)]
	ans = 0
	for i in range(n - 1):
		(u, v) = list(map(int, input().split()))
		l[u - 1][v - 1] = 1
		l[v - 1][u - 1] = 1
	for i in l:
		if i.count(1) == 1:
			ans += 1
	print(ans)
while TN != 0:
	solution()
	TN -= 1


from collections import defaultdict
n = int(input())
m = defaultdict(int)
for i in range(n - 1):
	(a, b) = map(int, input().split(' '))
	m[a] += 1
	m[b] += 1
r = 0
for i in range(1, n + 1):
	if m[i] == 1:
		r += 1
print(r)


n = int(input())
q = [0] * n
for i in range(n - 1):
	(u, v) = list(map(int, input().split()))
	q[u - 1] += 1
	q[v - 1] += 1
print(q.count(1))


N = int(input())
output = [0] * N
for i in range(N - 1):
	(u, v) = [int(v) for v in input().split(' ')]
	output[u - 1] += 1
	output[v - 1] += 1
print(output.count(1))


n = int(input())
d = {}
for i in range(n - 1):
	(s, t) = map(int, input().split())
	if s in d:
		d[s].append(t)
	else:
		d[s] = [t]
	if t in d:
		d[t].append(s)
	else:
		d[t] = [s]
total = 0
for j in d.keys():
	if len(d[j]) == 1:
		total += 1
print(total)


n = int(input())
pairs = []
remote = []
for i in range(n - 1):
	(n, k) = list(map(int, input().split()))
	pairs.append(n)
	pairs.append(k)
for i in pairs:
	if pairs.count(i) == 1:
		remote.append(i)
print(len(remote))


n = int(input())
a = n
p = {x: 0 for x in range(1, n + 1)}
for _ in range(n - 1):
	(u, v) = map(int, input().split())
	p[u] += 1
	p[v] += 1
	if p[u] == 2:
		a -= 1
	if p[v] == 2:
		a -= 1
print(a)


n = int(input())
f = [0 for i in range(n + 1)]
for i in range(n - 1):
	(x, y) = map(int, input().split())
	f[x] += 1
	f[y] += 1
print(f.count(1))


a = []
b = int(input())
e = 0
for i in range(b - 1):
	(d, c) = list(map(int, input().split()))
	a.append(d)
	a.append(c)
for i in range(1, b + 1):
	if a.count(i) == 1:
		e += 1
print(e)


a = int(input())
l = []
one = []
for i in range(a - 1):
	p = list((int(x) for x in input().split()))
	for i in p:
		l.append(i)
for i in set(l):
	one.append(l.count(i))
print(one.count(1))


n = int(input())
a = [0] * (n + 1)
for i in range(n - 1):
	(v1, v2) = [int(i) for i in input().split()]
	a[v1] += 1
	a[v2] += 1
print(a.count(1))


n = int(input())
l = []
for i in range(n - 1):
	(u, v) = map(int, input().split())
	l.append(u)
	l.append(v)
setl = set(l)
count1 = 0
for j in setl:
	if l.count(j) == 1:
		count1 += 1
print(count1)


n = int(input().strip())
graph = [[] for i in range(n)]
for _ in range(n - 1):
	(a, b) = map(int, input().split())
	graph[a - 1].append(b - 1)
	graph[b - 1].append(a - 1)
count = 0
for g in graph:
	if len(g) < 2:
		count += 1
print(count)


z = int(input())
all_connected = []
repeated = []
while z - 1:
	(n, k) = map(int, input().rstrip().split(' '))
	if n not in all_connected:
		all_connected.append(n)
	else:
		repeated.append(n)
	if k not in all_connected:
		all_connected.append(k)
	else:
		repeated.append(k)
	z = z - 1
print(len(all_connected) - len(list(set(repeated))))


(graph, num) = ({}, 0)
n = int(input())
for i in range(n - 1):
	(a, b) = [int(i) for i in input().split()]
	if a not in graph:
		graph[a] = []
	graph[a].extend([b])
	if b not in graph:
		graph[b] = []
	graph[b].extend([a])
for key in graph:
	if len(graph[key]) == 1:
		num += 1
print(num)


n = int(input())
d = {}
for i in range(n - 1):
	(u, v) = map(int, input().split())
	if u not in d:
		d[u] = 1
	else:
		d[u] += 1
	if v not in d:
		d[v] = 1
	else:
		d[v] += 1
ans = 0
for i in range(1, n + 1):
	if d[i] == 1:
		ans += 1
print(ans)


import sys
import math
import bisect

def main():
	n = int(input())
	A = [0] * n
	for i in range(n - 1):
		(a, b) = map(int, input().split())
		A[a - 1] += 1
		A[b - 1] += 1
	ans = 0
	for i in range(n):
		if A[i] == 1:
			ans += 1
	print(ans)
main()


N = int(input())
deg = [0] * N
for i in range(N - 1):
	(a, b) = map(int, input().split())
	deg[a - 1] += 1
	deg[b - 1] += 1
num = 0
for i in range(N):
	if deg[i] == 1:
		num += 1
print(num)


n = int(input())
dic = {}
for i in range(1, n + 1):
	dic.update({i: 0})
for i in range(n - 1):
	s = input().split()
	dic[int(s[0])] += 1
	dic[int(s[1])] += 1
count = 0
for x in dic.keys():
	if dic[x] == 1:
		count += 1
print(count)


resole = []
result = 0
for i in range(int(input()) - 1):
	resole.extend(list(map(lambda x: int(x), input().split(' '))))
resole.sort()
for i in range(1, len(resole) - 1):
	if not resole[i + 1] == resole[i] and (not resole[i - 1] == resole[i]):
		result += 1
if not resole[len(resole) - 1] == resole[len(resole) - 2]:
	result += 1
if not resole[0] == resole[1]:
	result += 1
print(result)


from collections import Counter
n = int(input())
l1 = []
while True:
	try:
		l = input().split()
		for i in l:
			l1.append(i)
	except:
		break
a = Counter(l1)
z = list(a.values())
print(z.count(1))