#include <stdio.h>
#include <limits.h>
#define inf INT_MAX
char str[2000002], ch;
int main()
{
int n, i;
while (scanf("%d", &n) == 1 && n)
{
getchar();
int R = 0, D = 0, Z = 0, min = inf, tmp;
gets(str);
for (i = 0; (ch = str[i]); i ++)
{
if (ch == '.') continue;
if (ch == 'D')
{
D = i + 1;
if (R) tmp = D - R;
if (tmp < min && R) min = tmp;
continue;
}
if (ch == 'R')
{
R = i + 1;
if (D) tmp = R - D;
if (tmp < min && D) min = tmp;
continue;
}
if (ch == 'Z')
{
min = inf;
break;
}
}
if (min == inf) printf("0\n");
else printf("%d\n", min);
}
return 0;
}
回目錄
回首頁
沒有留言 :
張貼留言