def f(a)
	s = 0
	a[0] -= 1
	if a[0] == 0
		a.shift
		(0..a.size-1).each{|i|
			b = a.dup
			b[i] -= 1
			b.delete_at(i) if b[i] == 0
			s += g(b)
		}
	else
		a[0] -= 1
		s += 720 / a.map{|x| fact(x)}.inject(:*)
		a[0] += 1
		(1..a.size-1).each{|i|
			b = a.dup
			b[i] -= 1
			b.delete_at(i) if b[i] == 0
			s += g(b)
		}
	end
	s
end

def g(a)
	k = a[0]
	s = 720 / a.map{|x| fact(x)}.inject(:*)
	if a == [6]
		s += 2
	elsif a == [3, 3]
		s += 4
	end
	s / 3
end

def fact(x)
	(1..x).inject(1, :*)
end

while gets
	hash = {}
	a = $_.chomp.split.group_by{|x| x}.values.map(&:size)
	p f(a)
end