Problem:
Score : 200 points

Problem Statement

You are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.

Here, a ACGT string is a string that contains no characters other than A, C, G and T.

Notes

A substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.

For example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.

Constraints

S is a string of length between 1 and 10 (inclusive).

Each character in S is an uppercase English letter.

Input

Input is given from Standard Input in the following format:

S

Output

Print the length of the longest ACGT string that is a substring of S.

Sample Input 1

ATCODER

Sample Output 1

3

Among the ACGT strings that are substrings of ATCODER, the longest one is ATC.

Sample Input 2

HATAGAYA

Sample Output 2

5

Among the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.

Sample Input 3

SHINJUKU

Sample Output 3

0

Among the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).

Solution in Rust (1.15.1) (judge verdict: Accepted)

use std::io;
use std::io::BufRead;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let mut count = 0;
    let mut res = 0;
    let s:String = sc.next();
    for c in s.chars() {
        match c {
            'A' | 'G' | 'C' | 'T' => {
                count += 1;
                res = std::cmp::max(res, count);
            },
            _ => {
                count = 0;
            }
        }
    }
    println!("{}", res);
}


//////////////////////////////
////////// template //////////
//////////////////////////////

/// ```
/// use contest::math;
/// assert_eq!(3, math::inv(2,5));
/// assert_eq!(1, math::inv(1,2));
/// assert_eq!(1, math::inv(3,2));
/// ```
pub fn inv(value: i32, modulo_prime: i32) -> i32 {
    return pow_mod(value, modulo_prime - 2, modulo_prime);
}

/// ```
/// use contest::math;
/// assert_eq!(8, math::pow_mod(2,3,10));
/// assert_eq!(1, math::pow_mod(3,4,10));
/// assert_eq!(1, math::pow_mod(0,0,3));
/// assert_eq!(0, math::pow_mod(0,0,1));
/// ```
pub fn pow_mod(value: i32, exponent: i32, modulo: i32) -> i32 {
    if exponent < 0 {
        panic!("Exponent should >= 0.");
    }
    if modulo == 1 {
        return 0;
    }
    let modulo = modulo as i64;
    let mut value = value as i64;
    if value >= modulo {
        value %= modulo;
    }
    if value < 0 {
        value = value % modulo + value;
    }
    let mut res = 1;
    let mut exponent = exponent;
    while exponent > 0 {
        if (exponent & 1) == 1 {
            res = res * value % modulo;
        }
        value = value * value % modulo;
        exponent >>= 1;
    }
    res as i32
}

/// ```
/// use contest::vec;
/// let mut is = vec![2,3,1];
/// assert!(vec::next_permutation(&mut is));
/// assert_eq!(vec![3,1,2], is);
/// assert!(vec::next_permutation(&mut is));
/// assert_eq!(vec![3,2,1], is);
/// assert!(!vec::next_permutation(&mut is));
/// assert_eq!(vec![1,2,3], is);
///
/// let mut is = (0..3).collect();
/// let mut count = 0;
/// loop {
///     count+=1;
///     // Do something using is
///     if !vec::next_permutation(&mut is) {
///         break;
///     }
/// }
/// assert_eq!(6, count);
///
/// let mut is = vec![1,2,1];
/// assert!(vec::next_permutation(&mut is));
/// assert_eq!(vec![2,1,1], is);
/// assert!(!vec::next_permutation(&mut is));
/// assert_eq!(vec![1,1,2], is);
/// ```
pub fn next_permutation(is: &mut Vec<i32>) -> bool {
    let n = is.len();
    for i in (1..n).rev() {
        let i = i as usize;
        if is[i - 1] < is[i] {
            let mut j = n - 1;
            while is[i - 1] >= is[j] {
                j -= 1;
            }
            is.swap(i - 1, j);
            reverse(is, i, n);
            return true;
        }
    }
    is.reverse();
    false
}

fn reverse(v: &mut Vec<i32>, from_inclusive: usize, to_exclusive: usize) {
    let mut i = from_inclusive;
    let mut j = to_exclusive - 1;
    while i < j {
        v.swap(i, j);
        i += 1;
        j -= 1;
    }
}
/// Scanner
///
/// # Example
/// ```
/// use contest::scanner;
/// let mut sc = scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
/// assert_eq!("1".to_string(), sc.next::<String>());
/// assert_eq!(2, sc.next());
/// assert_eq!(3.5, sc.next());
///
/// // To create a scanner from stdin:
/// scanner::new(std::io::stdin());
/// ```

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

pub fn new<R: io::Read>(r: R) -> Scanner<R> {
    Scanner::new(r)
}

impl<R: io::Read> Scanner<R> {
    #[inline]
    fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        self.next_string()
            .map(|s| s.parse::<T>().expect("Parse failed: "))
            .expect("Unexpected EOF")
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}

#[test]
fn next() {
    let mut sc = new("hoge".as_bytes());
    let s: String = sc.next();
    assert_eq!("hoge", s);
}