N, K = $<.map &:to_i M = 5e5 def valid_dice(n) n.times.map{rand(1..6)}.sum end def evil_dice(n) n.times.map{3+rand(1..3)}.sum end p (1..M).count{ valid_dice(N - K) + evil_dice(K) > valid_dice(N) } / M