def read
    s = gets.chomp
    return 0 if s == "NONE"
    return s.split(",").size
end

r,g,b = read,read,read
p (16-r)**2*(16-g)**2*(16-b)**2