#K54752. Smallest Distinct Substring

    ID: 29823 Type: Default 1000ms 256MiB

Smallest Distinct Substring

Smallest Distinct Substring

Given a string s, find the length of the smallest contiguous substring that contains all the distinct characters present in s at least once. Formally, if the set of distinct characters is \(D\), you are to determine the minimum length of a substring such that every character in \(D\) appears at least once.

Note: The input string consists of lowercase English letters only.

inputFormat

The input consists of a single line containing the string s. The length of s does not exceed \(10^5\) characters.

outputFormat

Output a single integer which is the length of the smallest contiguous substring that contains all the distinct characters of s.

## sample
aabcbcdbca
4