Simple Java Solution
Code\njava []\npublic class Node {\n    int x;\n    int y;\n\n    public Node(int i, int j) {\n        x = i;\n        y = j;\n    }\n}\n\nclass Solution {\n   
# Code\n```java []\npublic class Node {\n    int x;\n    int y;\n\n    public Node(int i, int j) {\n        x = i;\n        y = j;\n    }\n}\n\nclass Solution {\n    public int countHighestScoreNodes(int[] parents) {\n        long max=0;\n        HashMap<Integer,Node> map=new HashMap<Integer,Node>();\n        HashMap<Integer,Integer> h=new HashMap<Integer,Integer>();\n        Queue<Integer> q=new LinkedList<Integer>();\n        HashSet<Integer> hset=new HashSet<Integer>();\n        for(int i=0;i<parents.length;i++)\n        {\n            if(!h.containsKey(parents[i]))\n            {\n\n                h.put(parents[i],1);\n            }\n            else\n            {\n                h.put(parents[i],2);\n            }\n           hset.add(parents[i]);  \n        }\n        for(int i=0;i<parents.length;i++)\n        {\n          if(!hset.contains(i))\n          {\n            Node node=new Node(0,0);\n            map.put(i,node);\n            q.add(i);\n          }\n        }\n        hset=new HashSet<Integer>();\n        int count=0;\n        while(q.size()>0)\n        {\n            int m=q.poll();\n            Node node=map.get(m);\n            long p=1;\n            int c=node.x+node.y+1;\n            if(node.x!=0)\n            {\n                p=p*node.x;\n            }\n            if(node.y!=0)\n            {\n                p=p*node.y;\n            }\n            if(parents.length-c!=0)\n            {\n                p=p*(parents.length-c);\n            }\n            if(p>max)\n            {\n                count=1;\n                max=p;\n            }\n            else if(p==max)\n            {\n                count++;\n            }\n            if(parents[m]!=-1)\n            {\n                if(map.containsKey(parents[m]))\n                {\n                   Node n=map.get(parents[m]);\n                   n.y=node.x+node.y+1;\n                   map.put(parents[m],n);\n                   q.add(parents[m]);\n                }\n                else\n                {\n                   int z=node.x+node.y+1;\n                   Node n=new Node(z,0);\n                    map.put(parents[m],n);\n                   if(h.get(parents[m])==1)\n                   {\n                      q.add(parents[m]);\n                   }\n                }\n            }\n            \n        }\n        return count;\n    }\n}\n```
['Java']