#0002BC

O-packing

Mina, Anja, Toma and Cincibell are taking same class. They decided to buy a gift for their teacher. They've decide that ribbon is a suitable gift for her. They asked the salesman to pack the ribbon in a box, but the salesman has to know where to bend the gift. He first bends the ribbon to the left, and then to the right, and so on, until he finishes. If then ribbon can fit in box, he will pack it, otherwise they will bring the ribbon unpacked.

“You can tell me the list of the places to bend the ribbon, or just write them down for me” he said.


You know the length of ribbon, N (2 <= N <= 10^9), number of bending places K (1 <= K <= 100000), and all the places where ribbon will be bent, (all places will be sorted in an ascending order, and last place will be less then N), Determine the visible part of the ribbon after all the bending is performed.



InputThe first contains two integers N (ribbon length) and K (number of bending points) and one large letter ‘L’ or ’W’, separated with empty space.
Letter ‘L’, meaning “aloud”, in which case all places for packing will be listed in the second row, separated with white spaces.
Letter’W’ meaning “written” and in that case all the places for packing will be listed in next K rows, every place in a new row.

OutputOutput the length of the visible part of the ribbon after all bending is performed.

Picture of the first example.


Image: packing

Input:
10 4 L
1 3 6 7


Output:
5


Input:
9 5 W
1
2
5
7
8


Output:
3


Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.