Under construction

Still being built. Things may change

Rock is rock too

Interview

Time limit2sMemory limit512 MB

Summary
Count the subsequences of a string of up to 1,000,000 uppercase letters that spell ROCK, modulo 1e9+7.
Level

Easy3 of 10

Topics
Dynamic programming, String
Solved
No attempts yet

Problem

나락도 락이다. 부모님께 온 연락도 락이다. 오락가락?도 락? 이다.?

Given a string SS of length NN made of uppercase English letters, count its subsequences that end with ROCK. Print the count modulo 109+710^9+7.

Input

The first line contains the length NN of the string SS. (4≤N≤1 000 000)(4 \leq N \leq 1\ 000\ 000)

The second line contains the string SS, made of uppercase English letters only.

Output

Print the number of subsequences of SS that end with ROCK, modulo 109+710^9 + 7.

Hint

A subsequence of a string is a string obtained by deleting some characters from it. Deleting no characters is also allowed. For example, aan is a subsequence of hanyang.

Examples2

  1. Example 1

    Input
    6
    NAROCK
    
    Expected output
    4
    
  2. Example 2

    Input
    5
    RROCK
    
    Expected output
    3