This is simple in-degree counting problem. I decided to use Python 3 for this question due to the split method available in strings.
Find tons of competitive coding stuff here. I usually code in C++ and Python and rarely in Java during competitive coding. This blog is still under construction!