To unlock the first and second hokages, answer all ten questions asked by Ebisu. The third hokage can be unlocked by defeating the Heroes History mode. To unlock the fourth hokage, unlock each character in the game.
To unlock the first and second hokages, do the following. First, select Ultimate Contest mode and complete it. Then, head to the academy and talk to Udon and Moegi, successfully completing their ten riddles. From there, go to Shushuya Restaurant. Here you will meet Ebisu. Answer his riddles like you did the earlier characters. When completed, the first and second hokages will be unlocked.
The Fourth Hokage can be unlocked after you unlock all other characters.