4699: P8616 [蓝桥杯 2014 国 C] 套娃
          Memory Limit:128 MB
          Time Limit:1.000 S
         
      
      
        
          Judge Style:Text Compare
          Creator:
      
      
          Submit:0
          Solved:0
      
Description

Input

Output

Sample Input Copy
5 5
5 3
5 4
3 2
3 1
Q 1
Q 4
P 2
Q 1
Q 4Sample Output Copy
2
1
2
0
0HINT
