>>466 Ruby
def f(a,b)
r=0
v=b.chars
a.chars.combination(b.size){|x| r+=1 if x==v}
r
end