If I am a manager, the size of my team is: (Myself) The total team size of all my direct reports. For a leaf employee (no direct reports), the team size is (themselves). The boss's team includes the entire company.
This is classic tree DP. You compute the subtree size for each node by summing the subtree sizes of its children and adding . Then, the number of subordinates is subtree_size - . The leaf employees have subordinates.