$K=<>; @E[$K..$K+5]=(0)x6; $E[$_]=eval(join'+',@E[$_+1..$_+6])/6+1for reverse 0..$K-1; print$E[0]