Type: Default 1000ms 256MiB

银狼的字符串

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Problem Description

银狼的字符串签到

听说G题很适合放签到题?

是这样吗?

给定一个长度为 $n$ 的字符串 $s$,仅包含小写字母 `a` ~ `z`。

定义区间 $[l, r]$($1 \le l \le r \le n$)是「合法的」,当且仅当:子串 $s_{[l \ldots r]}$ 中的字符可以任意重新排列后,使 `silverwolf` 作为连续子串出现。区间的长度定义为 $r - l$。

求满足条件的最小合法区间长度。若不存在,输出 $-1$。

Input Format

第一行一个整数 $n$($1 \le n \le 10^6$)。

第二行一个长度为 $n$ 的字符串 $s$,仅包含小写字母 `a` ~ `z`。

Output Format

一行一个整数,表示最小合法区间长度。若不存在则输出 $-1$。

10
silverwolf

9

12
axsilverwolf

9

5
abcde

-1