COUNTREL Recursive relation

Please can anyone post how they came up with this recurrence formula.Thanks in Advance.http://discuss.codechef.com/questions/4187/countrel-editorial