atcoder#ABC299C. [ABC299C] Dango

[ABC299C] Dango

Score : 300300 points

Problem Statement

For a positive integer LL, a level-LL dango string is a string that satisfies the following conditions.

  • It is a string of length L+1L+1 consisting of o and -.
  • Exactly one of the first character and the last character is -, and the other LL characters are o.

For instance, ooo- is a level-33 dango string, but none of -ooo-, oo, and o-oo- is a dango string (more precisely, none of them is a level-LL dango string for any positive integer LL).

You are given a string SS of length NN consisting of the two characters o and -. Find the greatest positive integer XX that satisfies the following condition.

  • There is a contiguous substring of SS that is a level-XX dango string.

If there is no such integer, print -1.

Constraints

  • 1N2×1051\leq N\leq 2\times10^5
  • SS is a string of length NN consisting of o and -.

Input

The input is given from Standard Input in the following format:

NN

SS

Output

Print the greatest positive integer XX such that SS contains a level-XX dango string, or -1 if there is no such integer.

10
o-oooo---o
4

For instance, the substring oooo- corresponding to the 33-rd through 77-th characters of SS is a level-44 dango string. No substring of SS is a level-55 dango string or above, so you should print 44.

1
-
-1

Only the empty string and - are the substrings of SS. They are not dango strings, so you should print -1.

30
-o-o-oooo-oo-o-ooooooo--oooo-o
7