Counting on a directed graph | CodeChef