2 ){ $target[] = $a; } if ( $node[$b] > 2 ){ $target[] = $b; } } $target = array_unique( $target ); foreach( $target as $v ){ $ans += $node[$v] - 2; } print $ans."\n";