N = gets.to_i K = gets.to_i def f(n, m) @dp ||= {} @dp[[n, m]] ||= if n == 0 and m == 0 1.0 elsif n == 0 or m <= 0 0.0 elsif n <= K (4..6).map {|i| f(n - 1, m - i)}.inject(:+) / 3 else (1..6).map {|i| f(n - 1, m - i)}.inject(:+) / 6 end end def g(n, m) @dp2 ||= {} @dp2[[n, m]] ||= if n == 0 and m == 0 1.0 elsif n == 0 or m <= 0 0.0 else (1..6).map {|i| g(n - 1, m - i)}.inject(:+) / 6 end end ans = ((N + 1)..(6 * N)).map {|m| f(N, m) * (N...m).map {|l| g(N, l)}.inject(:+)}.inject(:+) puts ans