This is a post describing my solution for 617B - Шоколад.
For this problem, the key is recognizing that we can frame the problem of breaking the candy bar up into parts as a sequential decision process. Once we know how many decisions we can make at each stage, then we can just multiply the number of decisions and arrive at the final answer.