class List
    def initialize(val)
        @val = val
        @next = nil
        @code = nil
    end

    def merge(other)
        return self if !other
        new_head = self.class.new(@val + other.val)
        if @next
            new_head.next = @next.merge(other.next)
        else
            new_head.next = other.next
        end
        new_head
    end

    def encode
        return @val.to_s if !@next
        @code ||= @val.to_s + "," + @next.encode
    end

    attr_accessor :next
    attr_reader :val
end

require 'tsort'

class Hash
    include TSort
    alias tsort_each_node each_key

    def tsort_each_child(u)
        self[u].each do |v|
            yield v
        end
    end
end

n = gets.to_i
g = {}
(1..n).map {|v| g[v] = []}

(n-1).times do
    u, v = gets.split.map(&:to_i)
    g[u] << v
end

head = {}
g.tsort.each do |u|
    l = List.new(1)
    if !g[u].empty?
        merged = g[u].map {|v| head[v]}.inject {|m, l| m.merge(l)}
        l.next = merged
    end
    head[u] = l
end

group = Hash.new(0)
(1..n).each do |u|
    group[head[u].encode] += 1
end
p group.each_value.map {|k| k * (k-1)/2}.inject(:+)