Actually its the Fifth Time, Second Try(it's very confusing), and i couldn't find anything from Neoseeker on this, matter of fact every guide in there was no help to the game at all. This is from gamefaqs, hope it helps:
If you check the cabin beside the locked door where you will fight the bosses on this ship, you can find a secret chest which is locked by a special digit. This added notes will show you the rule to open it. Special thanks to Beno Jange for contributing this to my FAQ.
First Time 10 chances Stun Guard Second Time 8 chances Panic Guard Third Time 6 chances Magic Ego Bell Fourth Time 4 chances Talisman Fifth Time 2 chances Ultimate Wargod Sixth Time 2 chances 100G
The basic concept for the password are: 1. There are four numbers to be given as a password. 2. There are only three of them are used for password. 3. The four numbers should be changed to three numbers permutation and combination. 4. Each time if one or more numbers of the code are entered correctly (almost correct) then there will be a text displaying "...". However if all of numbers are entered incorrectly then there will be a text displaying how many chances are left. 5. If you get almost correct code (means that one or more number location of the code is correct) then compare it with other almost correct code and find the similarity. After that, negate the similarity to find the incorrect code and cross all other incorrect codes. However, if you enter the incorrect password (means that the number location of the code is incorrect) then cross all other incorrect codes. 6. Enter the password which is left by selection. Repeat step (4) and (6) if the password is still incorrect.
You are confused by my explanation, aren't you? OK, I will give you step by step solution. Remember to save each time you enter the correct codes. However, you ever have learned the permutation and combination in your school, haven't you?
 Case 1 
1. There are four numbers: 0258.
2. Three of them are used for password.
3. Do the permutation and combination for three numbers: 025 052 205 502 250 520 028 082 208 802 280 820 058 085 508 805 580 850 258 285 582 852 825 528
4. Enter one of the three numbers in the above for the password: 258.
5. If you received a text displaying how many chances are left then you enter the incorrect code. That means all of the number if 2 is placed 1st or 5 is placed 2nd or 8 is placed 3rd then it will be the incorrect numbers. The other incorrect password (from the list) if:  2 is placed 1st: 205, 250, 208, 280, (258), 285.  5 is placed 2nd: 052, 250, 058, 850, (258), 285, 852.  8 is placed 3rd: 028, 208, 058, 508, (258), 528. Cross them all for removing it from correct code selection.
6. The list should be contained: 025, 502, 520, 082, 802, 820, 085, 805, 580, 582, 825. Enter one of them: 820. Oh no! It's incorrect password. Don't worry. The other incorrect password (from the list) if:  8 is placed 1st: 802, (820), 805, 825.  2 is placed 2nd: 025, 520, (820), 825.  0 is placed 3rd: 520, (820), 580. Cross them all for removing it from correct code selection. The list should be contained: 502, 082, 085, 582. You only have to enter one of the four codes. It's better than entering 22 codes from the permutation and combination list!
 Case 2 
1. There are four numbers: 0025.
2. Three of them are used for password.
3. Do the permutation and combination for three numbers: 002 020 200 005 050 500 025 052 250 502 520 205
4. Enter one of the three numbers in the above for the password: 020.
5. If you received a text displaying "..." then you enter the almost correct code. Write it down. Enter another code: 200. You've got another almost correct code. Write it down. Now compare these two codes and find the similarity: 020 and 200. You'll see that the similarity is 0 is placed 3rd. Now negate the similarity so the incorrect password if 0 is not placed 3rd are: 002, 005, 025, 052, 502, 205. Cross them all from the list.
6. The list should be contained: (020), (200), 050, 500, 250, 520. You will only have to enter one of the four codes. It's better than entering 10 codes from the permutation and combination list!
 Case 3 
1. There are four numbers: 0123.
2. Three of them are used for password.
3. Do the permutation and combination for three numbers: 012 021 102 120 201 210 013 031 103 130 301 310 023 032 203 230 302 320 123 132 213 231 312 321
4. Enter one of the three numbers in the above for the password: 103.
5. If you received a text displaying how many chances are left then you enter the incorrect code. That means all of the number if 1 is placed 1st or 0 is placed 2nd or 3 is placed 3rd then it will be the incorrect numbers. The other incorrect password (from the list) if:  1 is placed 1st: 102, 120, (103), 130, 123, 132.  0 is placed 2nd: 102, 201, (103), 301, 203, 302.  3 is placed 3rd: 013, (103), 023, 203, 123, 213.
6. The list should be contained: 012, 021, 210, 031, 310, 032, 230, 320, 231, 312, 321. Enter one of them: 021. If you received a text displaying "..." then you enter the almost correct code. Write it down. Enter another one: 031. Oh no! It's almost correct password. Write it down. Now compare these two codes and find the similarity: 021 and 031. You'll see that the similarity is 1 is placed 3rd. Now negate the similarity so the incorrect password if 1 is not placed 3rd are: 012, 210, 310, 032, 230, 320, 312. Cross them all from the list. The list should be contained: (021), (031), 231, 321. You will only have to enter one of the two codes. It's better than entering 21 codes from the permutation and combination list!
The easiest way to determine the more exact code is by finding the incorrect code. The codes which come from four different numbers are quite hard to solve than the codes which come from three or less different numbers. You should pray hard that the ghost won't give you four different numbers. As I state in the beginning that save each time you successfully unlock the chest but not each time you get the numbers. Why? Your saved file won't save your numbers. In other words, each time you load your saved file then the four numbers will be different again so you have to go all the way to obtain the numbers from the ghosts.
