1. 

/**
* Problem: 11661 Burger Time
* Zeit: 0.356
* Programmiersprache: JAVA
* @author Christoph Miesel
* Status: ACCEPTED
*/


import java.io.*;

public class BurgerTime
{
static boolean R, D;
static int counter, min;

public static void main(String[] args) throws IOException
{
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
String line = r.readLine();
int length = Integer.parseInt(line);
while(true)
{
min = Integer.MAX_VALUE;
counter = 0;
R = false;
D = false;
if(length == 0)
break;
line = r.readLine();
for(int i = 0; i < length; i++)
{
if(!R && !D)
{
if(line.charAt(i) == 'Z')
{
min = 0;
break;
}
if(line.charAt(i) == 'D')
D = true;
if(line.charAt(i) == 'R')
R = true;
continue;
}
else
{
if(line.charAt(i) == 'Z')
{
min = 0;
break;
}
if(line.charAt(i) == '.')
{
counter++;
continue;
}
if(line.charAt(i) == 'D')
{
if(D)
{
counter = 0;
continue;
}
else
{
counter++;
D = true;
R = false;
if(min > counter)
min = counter;
counter = 0;
continue;
}
}
if(line.charAt(i) == 'R')
{
if(R)
{
counter = 0;
continue;
}
else
{
counter++;
D = false;
R = true;
if(min > counter)
min = counter;
counter = 0;
continue;
}
}
}
}
System.out.println(min);
line = r.readLine();
length = Integer.parseInt(line);
}
}
}