I have the answer, but not an explanation =/

Here's the problem which is *partially* completed:

There are five boxes labeled 0 through four. Your task is to put a digit from 0 through 4 inside each box so that this condition held:

* The digit you put in the box labeled "0" must be the same as the number of 0's you use. Same for the box labeled "1", and the box labeled "2"... and so on ...

We've been given a head start on this problem, the boxes should be filled with 1, 2, 1, 0, 0.

However, despite my several attempts, I can not figure out a logical way to get to this answer. Obviously, an answer alone doesn't help me learn. So an explanation is appreciated!