output_description: Print the minumum value of K, the number of antennas, when the condition is
  satisfied.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      a_0 b_0
      a_1 b_1
      :
      a_{N - 2} b_{N - 2}
attempt: def examA():
      N = I()
      ans = 0
      print(ans)
      return
  
  
  def examB():
      ans = 0
      print(ans)
      return
  
  
  def examC():
      ans = 0
      print(ans)
      return
  
  
  def examD():
      #############################################################
      class UnionFind:
          def __init__(self, n):
              self.parent = [-1 for _ in range(n)]
              self.n = n
              # 正==子: 根の頂点番号 / 負==根: 連結頂点数
  
          def find(self, x):
              # 要素xが属するグループの根を返す
              if self.parent[x] < 0:
                  return x
              else:
                  self.parent[x] = self.find(self.parent[x])
                  return self.parent[x]
  
          def unite(self, x, y):
              # 要素xが属するグループと要素yが属するグループとを併合する
              x, y = self.find(x), self.find(y)
              if x == y:
                  return False
              else:
                  if self.size(x) < self.size(y):
                      x, y = y, x
                  self.parent[x] += self.parent[y]
                  self.parent[y] = x
  
          def same(self, x, y):
              # 要素x, yが同じグループに属するかどうかを返す
              return self.find(x) == self.find(y)
  
          def size(self, x):
              # 要素xが属するグループのサイズ（要素数）を返す
              x = self.find(x)
              return -self.parent[x]
  
          def is_root(self, x):
              # 要素の根をリストで返す
              return self.parent[x] < 0
  
          def roots(self):
              # すべての根の要素をリストで返す
              return [i for i, x in enumerate(self.parent) if x < 0]
  
          def members(self, x):
              # 要素xが属するグループに属する要素をリストで返す
              root = self.find(x)
              return [i for i in range(self.n) if self.find(i) == root]
  
          def group_count(self):
              # グループの数を返す
              return len(self.roots())
  
          def all_group_members(self):
              # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
              return {r: self.members(r) for r in self.roots()}
  
      ################################################################################
      N, M = LI()
      a = LI()
      ans = 0
      uf = UnionFind(N)
      for _ in range(M):
          x, y = LI()
          if not uf.same(x, y):
              uf.unite(x, y)
      D = defaultdict(int)
      rep = defaultdict(bool)
      r = uf.roots()
      keep = [-1] * N
      for i in range(N):
          parent = uf.find(i)
          if (not D[parent]) or D[parent] > a[i]:
              D[parent] = a[i]
              keep[parent] = i
      for i in range(N):
          if keep[i] == -1:
              continue
          rep[keep[i]] = True
          ans += D[i]
      loop = uf.group_count() - 2
      if loop == -1:
          print(0)
          return
      A = []
      for i, j in enumerate(a):
          A.append([j, i])
      A.sort()
      cur = 0
      for i in range(N):
          if cur >= loop:
              break
          if not rep[A[i][1]]:
              cur += 1
              ans += A[i][0]
      if cur < loop:
          print("Impossible")
          return
      print(ans)
      return
  
  
  def examE():
      def bfs(n, e, fordfs):
          # 点の数、スタートの点、有向グラフ
          W = [-1] * n
          # 各点の状態量、最短距離とか,見たかどうかとか
          W[e] = 0
          que = deque()
          que.append(e)
          while que:
              now = que.popleft()
              nowW = W[now]
              for ne in fordfs[now]:
                  if W[ne] == -1:
                      W[ne] = nowW + 1
                      que.append(ne)
          return W
  
      N = I()
      V = [[] for _ in range(N)]
      for _ in range(N - 1):
          a, b = LI()
          V[a].append(b)
          V[b].append(a)
      L1 = bfs(N, 0, V)
      L2 = bfs(N, L1.index(max(L1)), V)
      if max(L2) == N - 1:
          print(1)
          return
      ans = 2
      for i in range(N):
          cur = len(V[i])
          if cur >= 4:
              ans += cur - 3
      print(ans)
      return
  
  
  def examF():
      ans = 0
      print(ans)
      return
  
  
  import sys, copy, bisect, itertools, heapq, math
  from heapq import heappop, heappush, heapify
  from collections import Counter, defaultdict, deque
  
  
  def I():
      return int(sys.stdin.readline())
  
  
  def LI():
      return list(map(int, sys.stdin.readline().split()))
  
  
  def LFI():
      return list(map(float, sys.stdin.readline().split()))
  
  
  def LSI():
      return list(map(str, sys.stdin.readline().split()))
  
  
  def LS():
      return sys.stdin.readline().split()
  
  
  def SI():
      return sys.stdin.readline().strip()
  
  
  global mod, mod2, inf, alphabet
  mod = 10**9 + 7
  mod2 = 998244353
  inf = 10**18
  alphabet = [chr(ord("a") + i) for i in range(26)]
  
  if __name__ == "__main__":
      examE()
  
  """
  
  """
  
problem_description: Statement
  
  We have a tree with N vertices. The vertices are numbered 0 through N - 1, and
  the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of
  vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number
  of edges in the path u-v.
  
  It is expected that one of the vertices will be invaded by aliens from outer
  space. Snuke wants to immediately identify that vertex when the invasion
  happens. To do so, he has decided to install an antenna on some vertices.
  
  First, he decides the number of antennas, K (1 ≤ K ≤ N). Then, he chooses K
  different vertices, x_0, x_1, ..., x_{K - 1}, on which he installs Antenna 0,
  1, ..., K - 1, respectively. If Vertex v is invaded by aliens, Antenna k (0 ≤
  k < K) will output the distance d(x_k, v). Based on these K outputs, Snuke
  will identify the vertex that is invaded. Thus, in order to identify the
  invaded vertex no matter which one is invaded, the following condition must
  hold:
  
    * For each vertex u (0 ≤ u < N), consider the vector (d(x_0, u), ..., d(x_{K - 1}, u)). These N vectors are distinct.
  
  Find the minumum value of K, the number of antennas, when the condition is
  satisfied.
samples: [{"input": "5\n    0 1\n    0 2\n    0 3\n    3 4", "output": "2\n    \n\nFor example, install an antenna on Vertex 1 and 3. Then, the following five\nvectors are distinct:\n\n  * (d(1, 0), d(3, 0)) = (1, 1)\n  * (d(1, 1), d(3, 1)) = (0, 2)\n  * (d(1, 2), d(3, 2)) = (2, 2)\n  * (d(1, 3), d(3, 3)) = (2, 0)\n  * (d(1, 4), d(3, 4)) = (3, 1)\n\n* * *"}, {"input": "2\n    0 1", "output": "1\n    \n\nFor example, install an antenna on Vertex 0.\n\n* * *"}, {"input": "10\n    2 8\n    6 0\n    4 1\n    7 6\n    2 3\n    8 6\n    6 9\n    2 4\n    5 8", "output": "3\n    \n\nFor example, install an antenna on Vertex 0, 4, 9."}]