Genealogic tree
There was a lot of relatives on Ira's birthday party, so that to remember them all was not so easy task. In order to obtain an overall picture, the idea to make a family tree was born. Due to error in one of tree building procedures it turned out that the tree was not binary, although the number of vertices was correct — 2^k-1.
— Something is wrong here. — Really? — I propose to double-check everything. — Specifically. — Divide the tree into connected parts of 2^i vertices, and each of us will check his part. — Why do you want to do that this way? — I do not know, I just like powers of two, and also the sum will be exactly what we need. Although there is a little problem: you can do that in a bunch of ways. — Yes, I remember the student's record-books, and Sudoku. How many ways are here this time? — You have a great memory, give me a few minutes to think about it. — Catch it.
Input
The first line contains an integer N=2^k-1 — number of vertices in the tree (1 ≤ k ≤ 12). The next line contains N-1 integers. Integer a_i (1 ≤ a_i < i+1) on i-th position denotes that there is an edge between vertices i+1 and a_i. Vertices are numbered starting from 1.
Output
Print a single integer — the number of ways to divide the tree into exactly k connected blocks of sizes 1, 2, 4, ..., 2^k-1. Each vertex must belong to exactly one block.