#define LEFT -1
#define RIGHT 1
#include <iostream>
char* step(char* board, long n, char* robot, int dir) {
if (robot == nullptr) {
throw "you fucked it up idiot!!!";
}
while (robot >= board && robot < board + n*sizeof(char)) {
robot += dir*sizeof(char);
if (*robot == '*') {
return robot;
}
}
return nullptr;
}
void print_board(char* board, long n) {
for (int i = 0; i < n; i++) {
std::cout << board[i];
}
}
int main() {
long n;
std::cin >> n;
char *board = (char*) malloc((1+n) * sizeof(char));
std::cin >> board;
long long steps = 0;
long coins_collected = 0;
char *robot_ptr;
for (long i = 0; i < n; i++) {
if (board[i] == 'R') {
robot_ptr = board + i;
break;
}
}
char *left_ptr = step(board, n, robot_ptr, LEFT);
char *right_ptr = step(board, n, robot_ptr, RIGHT);
while (
!(left_ptr == nullptr && right_ptr == nullptr) && (
( // either but not both is null
left_ptr == nullptr || right_ptr == nullptr
) ||
( // both are not null and not in middle
(long)(right_ptr - board) + (long)(left_ptr - board)
!= 2*(long)(robot_ptr - board)
)
)
) {
std::cout << (long)(left_ptr - board) << ' ' << (long)(robot_ptr - board) << ' ' << (long)(right_ptr - board) << '\n';
// closer to left?
if (
(robot_ptr - left_ptr < right_ptr - robot_ptr) && left_ptr != nullptr
) {
// go left
steps += robot_ptr - left_ptr;
robot_ptr = left_ptr;
left_ptr = step(board, n, left_ptr, LEFT);
} else {
// go right
steps += right_ptr - robot_ptr;
robot_ptr = right_ptr;
right_ptr = step(board, n, right_ptr, RIGHT);
}
coins_collected++;
}
std::cout << steps << ' ' << coins_collected << std::endl;
return 0;
}