if !ENV['RUBY_THREAD_VM_STACK_SIZE'] exec({'RUBY_THREAD_VM_STACK_SIZE'=>'10000000'}, '/usr/bin/ruby', $0) else N = gets.to_i E = Array.new(N + 1) { [] } (N - 1).times do u, v = gets.split.map(&:to_i) E[u] << v E[v] << u end used = Array.new(N + 1, false) def dfs(u, parent, used) has_child = false E[u].each do |v| next if v == parent dfs(v, u, used) has_child = true if used[v] end used[u] = true if not has_child end dfs(1, -1, used) puts used.count(true) end