Burger Time?#784

Burger Time?

2 seconds
64 megabytes
Very easy

Everybody knows that along major highways there are countless fast food restaurants—hamburgers, hot dogs, pizzas, sandwiches—so food can be found everywhere.

Often, the problem is not finding a restaurant but a drugstore. After a big lunch with fast food, it is normal to need a drugstore because your stomach might begin to hurt.

Given the locations of restaurants and drugstores on a highway, determine the minimum distance between a restaurant and a drugstore.

Input

The first line of each test case contains an integer (1 \leq L \leq 2\,000\,000), the length of the highway.

The second line contains a string of length that shows the positions of restaurants and drugstores along the highway, as follows:

  • The character R represents a place with a restaurant.

  • The character D represents a place with a drugstore.

  • The character Z represents a place with both a restaurant and a drugstore.

  • The character . represents an empty place.

You may assume each test case has at least one restaurant and at least one drugstore.

The end of input is indicated when L = 0.

Output

For each case in the input, print one line with the minimum distance between a restaurant and a drugstore.

Examples

Example 1

Loading
Loading