simple java solution using hashmap
```\n// if you found my solution usefull please upvote it\nclass Solution \n{\n    public HashMap hash;\n    public int dfs(int i,List[] adj,int totalNodes)\n  
```\n// if you found my solution usefull please upvote it\nclass Solution \n{\n    public HashMap<Long,Integer> hash;\n    public int dfs(int i,List<Integer>[] adj,int totalNodes)\n    {\n        int sumOfNodes=0;\n        long product=1l;\n        for(int curr : adj[i])\n        {\n            int currNodes=dfs(curr,adj,totalNodes);\n            sumOfNodes+=currNodes;\n            product*=currNodes;\n        }\n        int upNodes=(totalNodes-sumOfNodes-1);\n        if(upNodes>0) product*=upNodes;\n        hash.put(product,hash.getOrDefault(product,0)+1);\n        return sumOfNodes+1;\n    }\n    public int countHighestScoreNodes(int[] parents) \n    {\n        List<Integer>[] adj=new ArrayList[parents.length];\n        for(int i=0;i<parents.length;i++)  adj[i]=new ArrayList();\n        for(int i=1;i<parents.length;i++)\n        {\n            adj[parents[i]].add(i);\n        }\n        hash=new HashMap<>();\n        dfs(0,adj,parents.length);\n        long max=0;\n        for(long i : hash.keySet()) max=Math.max(max,i);\n        return hash.get(max);\n    }\n}
['Java']