Improved answer of P1_3

consider the situation that one character happens more than 1 time