## MOZESLS - Sharmeen Loves Substring [ EASY ]

After solving the problem “**MOZHSLM**” Sharmeen become familiar with subsequence and somehow become interested in substring. Instead of learning more about substring she started asking some ludicrous questions to Mozahid about substring. Become tired of answering Sharmeen’s ludicrous questions Mozahid gives Sharmeen another problem which is slightly harder than the previous one. Mozahid will give Sharmeen a string of lowercase English letters and some queries. In each query he will give her a substring of that string. Sharmeen has to answer how many different subsequence of ‘**sms**’ exists in that substring. Can you help Sharmeen solving this problem?

### Input

Given a string of lowercase English letters of length N (1 <= N <= 100) in first line. In the second line given an integer Q (1 <= Q <= 50), which is the number of queries. In each query you will be given two integer L, R (1 <= L <= R <= N). L is the starting position of the substring and R is the ending position of the substring (1 based position).

### Output

For each query you have to output an integer in one line which is the number of different subsequence of ‘sms’ in that substring.

**N.B.** Substring is a consecutive sequence of characters of a string. Where subsequence not necessarily need to be consecutive. But for both you have to maintain the order. For clearance ‘skmjssm’ has 2 different subsequence of ‘sms’. {1, 3, 5} and {1, 3, 6} (1 based position). For better understanding see the sample input output.

### Example

Input:sasmasamsas 3 1 6 3 9 8 11Output:2 4 0

[ This problem originally written by MD. Mozahidul Islam Bhuiyan (kissu_pari_na) ]

Added by: | Avik Sarkar |

Date: | 2018-06-22 |

Time limit: | 1s |

Source limit: | 50000B |

Memory limit: | 1536MB |

Cluster: | Cube (Intel G860) |

Languages: | All |

Resource: | Own |