logo AlgoBeat OnlineJudge
登录 注册

#212508. [NERC2023] LOL Lovers

内存限制:1024 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

There are food items lying in a row on a long table. Each of these items is either a loaf of bread (denoted as a capital Latin letter with ASCII code 76) or an onion (denoted as a capital Latin letter with ASCII code 79). There is at least one loaf of bread and at least one onion on the table.

You and your friend want to divide the food on the table: you will take a prefix of this row (several leftmost items), and the friend will take the rest. However, there are several restrictions:

  • Each person should have at least one item.
  • The number of your loaves should differ from the number of your friend's loaves.
  • The number of your onions should differ from the number of your friend's onions.

Find any correct division and print the number of items you take or report that there is no answer.

输入格式

The first line contains one integer () --- the number of food items on the table. The second line contains a string of length consisting of letters and . -th symbol represents the type of the -th food item on the table: stands for a loaf of bread, and stands for an onion. It is guaranteed that this string contains at least one letter and at least one letter .

输出格式

Print one integer --- a number such that, if you take leftmost items and your friend takes the remaining items, each of you and your friend get at least one item, your number of loaves is different from your friend's, and your number of onions is different from your friend's. If there are several possible answers, print any of them. If there are no possible answers, print the number .

样例

样例输入 1

3
LOL

样例输出 1

-1

样例输入 2

2
LO

样例输出 2

1

样例输入 3

4
LLLO

样例输出 3

1

样例输入 4

4
OLOL

样例输出 4

-1

样例输入 5

10
LLOOOOLLLO

样例输出 5

5

数据范围与提示

In the first example, in any division the left and the right part contain one loaf of bread.

In the second example, the division is and , and in these two strings the number of loaves is different (1 and 0) and the number of onions is different (0 and 1).

In the third example, any number 1, 2 or 3 is a correct answer.