gets

a, b = 0, 0
ARGF.each do |line|
  ary = line.chomp.split
  str0 = ary[0]
  str1 = ary[1]
  ary.sort!
  if str0 == str1
    a += 1
    b += 1
  elsif ary[0] == str0
    b += 3
  elsif ary[1] == str1
    a += 3
  end
end