There is a fishing game as following: The game contains nnn stages, numbered from 111 to nnn. There are four types of stages (numbered from 000 to 333): type 000: Ther
There is a fishing game as following: The game contains nnn stages, numbered from 111 to nnn. There are four types of stages (numbered from 000 to 333): type 000: There are no fish and no clam in this stage. type 111: There are no fish and one clam in this stage. type 222: There are one fish and no clam in this stage. type 333: There are one fish and one clam in this stage. In each stage, you can do exactly one of the following four actions. If there is a clam in the stage, you can use this clam to make one pack of fish bait. And the number of packs of fish bait you have is increased by one. You can use this pack of fish bait to catch fish after this stage. If there is one fish in the stage, you can catch this fish without any fish bait. After this stage, the number of packs of fish bait you have is not changed. If you have at least one pack of fish bait. You can always catch one fish by using exactly one pack of fish bait even if there are no fish in this stage. After this stage, the number of packs of fish bait you have is decreased by one. You can do nothing. Now, you are given nnn and the type of each stage. Please calculate the largest number of fish you can get in the fishing game.