1 #include <iostream>
2 #include <algorithm>
3 #include <string>
4 #include <cstring>
5
6 #define INF 0xfffffff
7 using namespace std;
8 const int maxn = 26;
9 int a[maxn];
10
11 bool is_ok(){
12 for (int i = 0; i < 26; i++){
13 if (!a[i])
14 return false;
15 }
16 return true;
17 }
18
19 int main(){
20 ios::sync_with_stdio(false);
21 string s;
22 cin >> s;
23 memset(a, 0, sizeof(a));
24 bool flag = true;
25 a[s[0] - 'A']++;
26 int ans = INF;
27 int l = 0;
28 for (int i = 1; i < s.length(); i++){
29 a[s[i] - 'A']++;
30 while (is_ok())
31 {
32 ans = min(ans, i - l + 1);
33 a[s[l++] - 'A']--;
34 }
35 }
36 if (ans == INF){
37 cout << "No Solution" << endl;
38 }
39 else
40 cout << ans << endl;
41 system("pause");
42 return 0;
43 }