#C494. Detecting Ordered Subsequence 'abc'

    ID: 48533 Type: Default 1000ms 256MiB

Detecting Ordered Subsequence 'abc'

Detecting Ordered Subsequence 'abc'

Given a non-empty string consisting of lowercase English letters, your task is to determine whether there exists a contiguous substring that contains the letters a, b, and c in that specific order. In other words, you need to check if there exist indices \(i < j < k\) in some contiguous segment of the string such that the segment contains at least one 'a', followed by at least one 'b', and then at least one 'c'.

If such a substring exists, output \(3\). Otherwise, output \(0\). Note that even if there are multiple substrings satisfying the condition, the answer remains \(3\) since it represents the length of the required pattern.

inputFormat

The input consists of a single line containing the string \(s\). The string is composed of lowercase English letters only. It is read from standard input.

outputFormat

Output a single integer which is \(3\) if there exists a contiguous substring of \(s\) in which 'a', 'b', and 'c' appear in order; otherwise, output \(0\). The output should be printed to standard output.

## sample
abacbcab
3