AtCoder Beginner Contest 122 - ATCoder

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-----
ATCODER

-----Sample Output-----
3

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

Source: atcoder | Difficulty: EASY


Solutions:
S = input()
length = 0
for i in range(0, len(S) + 1):
	for j in range(i, len(S) + 1):
		T = S[i:j]
		if T.replace('A', '').replace('C', '').replace('G', '').replace('T', '') == '':
			if len(T) > length:
				length = len(T)
print(length)


m = a = 0
for c in input():
	if c in 'ATGC':
		m += 1
	else:
		a = max(a, m)
		m = 0
else:
	print(max(a, m))


a = input()
atcg = ['A', 'T', 'C', 'G']
result = []
res = 0
for i in a:
	if i in atcg:
		res += 1
	else:
		res = 0
	result.append(res)
print(max(result))


S = input()
cnt = 0
maxv = 0
for i in range(len(S)):
	if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or (S[i] == 'T'):
		cnt += 1
		if cnt > maxv:
			maxv = cnt
	else:
		cnt = 0
print(maxv)


import re
result = re.findall('[ATCG]+', input(), re.S)
if len(result) > 0:
	print(max(list(map(len, result))))
else:
	print(0)


print(max([len(x) for x in ''.join(['a' if t == 'A' or t == 'T' or t == 'G' or (t == 'C') else ',' for t in input()]).split(',')]))


import re
s = str(input())
s = re.split('[^ACGT]', s)
ans = 0
for i in range(len(s)):
	ans = max(ans, len(s[i]))
print(ans)


s = input()
c = 0
an = 0
for i in s:
	if i in 'ACGT':
		c += 1
		an = max(an, c)
	else:
		c = 0
print(an)


s = input()
for i in s:
	if i not in 'ACGT':
		s = s.replace(i, '1')
s = s.split('1')
print(len(max(s, key=len)))


s = list(input()) + ['X']
l = ['A', 'G', 'C', 'T']
for i in range(len(s)):
	if s[i] in l:
		s[i] = 1
	else:
		s[i] = 0
cnt = 0
li = []
for i in range(len(s)):
	if s[i] == 1:
		cnt += 1
	else:
		li.append(cnt)
		cnt = 0
print(max(li))


s = input()
ans = 0
tmp = 0
for i in range(len(s)):
	for j in range(i, len(s)):
		if s[j] == 'A' or s[j] == 'C' or s[j] == 'G' or (s[j] == 'T'):
			tmp += 1
		else:
			ans = max(ans, tmp)
			tmp = 0
			break
	else:
		ans = max(ans, tmp)
		tmp = 0
print(ans)


s = input()
S = ''
for i in s:
	if i in 'ACGT':
		S += '1'
	else:
		S += '0'
print(max(list(map(len, S.split('0')))))


s = input()
n = 0
ans = 0
for i in s:
	if i in 'ACGT':
		n += 1
	else:
		n = 0
	ans = max(ans, n)
print(ans)


S = input()
cnt = 0
ans = 0
for ss in S:
	if ss in 'ACGT':
		cnt += 1
	else:
		cnt = 0
	ans = max(ans, cnt)
print(ans)


import re
s = input()
s1 = re.sub('[BD-FH-SU-Z]', '*', s)
s2 = s1.split('*')
l1 = [len(s2[i]) for i in range(len(s2))]
print(max(l1))


import re
S = input()
l = re.findall('[ACGT]+', S)
if l:
	print(max(map(len, l)))
else:
	print(0)


s = input()
l = 'ACGT'
ans = 0
most = 0
for i in s:
	if i in l:
		ans += 1
	else:
		ans = 0
	if ans > most:
		most = ans
print(most)


S = input()
N = len(S)
ans = 0
for i in range(N):
	for j in range(i, N):
		T = list(S[i:j + 1])
		M = j - i + 1
		flag = True
		for k in range(M):
			if T[k] != 'A' and T[k] != 'C' and (T[k] != 'G') and (T[k] != 'T'):
				flag = False
				break
		if flag:
			ans = max(ans, M)
print(ans)


S = ''.join([i if i in 'ACGT' else ' ' for i in input()])
print(max([len(i) for i in S.split()] + [0]))


m = t = 0
for (_, c) in enumerate(input()):
	t += 1 if 'ACGT'.find(c) >= 0 else -t
	m = max(m, t)
print(m)


s = input()
a = 0
b = 0
for i in s:
	if i in 'ATCG':
		a += 1
	else:
		b = max(a, b)
		a = 0
print(max(a, b))


import re
print(max((len(i) for i in re.sub('[^ACGT]', '_', input()).split('_'))))


import re
S = str(input())
ans = 0
for i in re.findall('[ACGT]*', S):
	if ans < len(i):
		ans = len(i)
print(ans)


s = list(input())
c = 0
ans = [0]
for i in s:
	if i == 'A' or i == 'C' or i == 'G' or (i == 'T'):
		c += 1
	else:
		c = 0
	ans.append(c)
print(max(ans))


S = input()
max_ = 0
for i in range(len(S)):
	for j in range(i, len(S)):
		if all(('ACGT'.count(c) == 1 for c in S[i:j + 1])):
			max_ = max(j + 1 - i, max_)
print(max_)


str_list = list(input())
count = 0
max_count = 0
for char in str_list:
	if char == 'A' or char == 'C' or char == 'G' or (char == 'T'):
		count += 1
	else:
		if count > max_count:
			max_count = count
		count = 0
if count > max_count:
	max_count = count
print(max_count)


s = list(input())
rmax = 0
r = 0
for ss in s:
	if ss in ['A', 'C', 'G', 'T']:
		r += 1
	else:
		rmax = max(rmax, r)
		r = 0
rmax = max(rmax, r)
print(rmax)


target_a = ['A', 'C', 'G', 'T']

def main():
	S = str(input())
	max_cnt = 0
	cnt = 0
	for s in S:
		if s in target_a:
			cnt += 1
		else:
			if cnt > max_cnt:
				max_cnt = cnt
			cnt = 0
	if cnt > max_cnt:
		max_cnt = cnt
	print(max_cnt)

def __starting_point():
	main()
__starting_point()


import re
m = re.findall('[ATCG]+', input())
if m:
	print(max([len(x) for x in m]))
else:
	print('0')


import re
s = input()
r = [0]
for i in re.finditer('[ACGT]+', s):
	r.append(len(i.group()))
print(max(r))


import re
x = input()
match = re.findall('[ACGT]+', x)
if match:
	print(max([len(x) for x in match]))
else:
	print(0)


import re
ans = max(map(len, re.findall('[ACGT]*', input())))
print(ans)


s = input() + 'I'
List = []
for i in range(len(s)):
	count = 0
	for j in range(len(s) - i):
		if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or (s[i] == 'C'):
			count += 1
			i += 1
		else:
			List.append(count)
			break
print(max(List))


s = input()
ans = []
x = 0
for i in range(len(s)):
	if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or (s[i] == 'T'):
		x += 1
	else:
		ans.append(x)
		x = 0
ans.append(x)
print(max(ans))


import re
print(len(max(re.split('[^ACGT]', input()), key=len)))


import re
S = input()
r = re.findall('[ACTG]+', S)
print(max([len(_) for _ in r], default=0))


S = str(input())
N = len(S)
cnt = [0 for i in range(N)]
for i in range(N):
	if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or (S[i] == 'T'):
		cnt[i] += 1
		for j in range(i + 1, N):
			if S[j] == 'A' or S[j] == 'C' or S[j] == 'G' or (S[j] == 'T'):
				cnt[i] += 1
			else:
				break
print(max(cnt))


import re
print(max((x.end() - x.start() for x in re.finditer('[ACGT]*', input()))))


import re
print(max(map(len, re.split('[^ACGT]', input()))))


from re import findall
S = input()
f = findall('[ACGT]*', S)
l = map(len, f)
print(max(l))


from re import findall
s = input()
res = findall('[ACGT]*', s)
max_len = max(map(len, res))
print(max_len)


S = input()
ans = 0
for i in range(len(S)):
	cnt = 0
	for j in range(i, len(S)):
		if S[j] in ['A', 'C', 'G', 'T']:
			cnt += 1
		else:
			break
	ans = max(ans, cnt)
print(ans)


s = input()
count = 0
max_count = 0
for i in range(len(s)):
	if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or (s[i] == 'C'):
		count += 1
	elif max_count < count:
		max_count = count
		count = 0
	else:
		count = 0
print(max(max_count, count))


S = input()
res = 0
cnt = 0
for i in range(len(S)):
	if S[i] in ['A', 'T', 'G', 'C']:
		cnt += 1
	else:
		res = max(res, cnt)
		cnt = 0
res = max(res, cnt)
print(res)


import itertools
S = input()
ans = 0
for (i, j) in itertools.combinations(list(range(len(S) + 1)), 2):
	if all(('ACTG'.count(c) == 1 for c in S[i:j])):
		ans = max(ans, len(S[i:j]))
print(ans)


s = list(input())
n = len(s)
res = 0
for i in range(n):
	for j in range(i, n):
		temp = s[i:j + 1]
		if all((i in 'ATGC' for i in temp)):
			res = max(res, len(temp))
print(res)


s = input()
l = len(s)
cnt = 0
ans = 0
for i in range(l):
	if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or (s[i] == 'T'):
		cnt += 1
		if ans < cnt:
			ans = cnt
	else:
		cnt = 0
print(ans)


S = input()
s_len = len(S)
ACGT = {'A', 'C', 'G', 'T'}
max_len = 0
max_str = ''
str = ''
for i in range(s_len):
	str = ''
	for j in range(i, s_len):
		if S[j] in ACGT:
			str += S[j]
			if len(str) >= max_len:
				max_len = len(str)
				max_str = str
		else:
			str = ''
print(max_len)


S = input()
ans = 0
acgt = ['A', 'C', 'G', 'T']
for i in range(len(S)):
	if S[i] in acgt:
		cnt = 0
		j = i
		while j < len(S) and S[j] in acgt:
			cnt += 1
			j += 1
		ans = max(ans, cnt)
print(ans)


import re
s = input()
print(max(map(len, re.split('[^ATCG]', s))))


s = input()
cnt = 0
mx = 0
for i in s:
	if i in 'ATGC':
		cnt += 1
		mx = max(cnt, mx)
	else:
		cnt = 0
print(mx)


s = input()
ans = 0
cnt = 0
for c in s:
	if c in 'ATCG':
		cnt += 1
	else:
		cnt = 0
	ans = max(ans, cnt)
print(ans)


X = ['A', 'C', 'G', 'T']
S = input()
sum = 0
ans = 0
for i in S:
	if i in X:
		sum += 1
	else:
		sum = 0
	ans = max(sum, ans)
print(ans)


s = input()
(a, l) = (0, 0)
for i in s:
	if i in 'ATGC':
		l += 1
	else:
		l = 0
	a = max(a, l)
print(a)


S = input()
m = 0
count = 0
for s in S:
	if s in 'AGCT':
		count += 1
	else:
		count = 0
	m = max(m, count)
print(m)


s = input()
m = 0
cnt = 0
for i in s:
	if i in 'ACGT':
		cnt += 1
	else:
		cnt = 0
	m = max(m, cnt)
print(m)


import re
s = input()
print(max(map(len, re.sub('[^ATCG]', '1', s).split('1'))))


import re
ll = list(map(len, re.sub('[^ACGT]', ' ', input()).split()))
if len(ll) == 0:
	print(0)
else:
	print(max(ll))


print(len(max(''.join((str(int(c in 'ATGC')) for c in input())).split('0'))))


import re
istr = input()
print(max([len(e) for e in re.split('[BDEFHIJKLMNOPQRSUVWXYZ]', istr)]))


import re
s = input()
sr = re.split('[^ATGC]', s)
print(len(max(sr, key=len)))


import re
s = input()
m = re.findall('[A|T|G|C]+', s)
if len(m) == 0:
	print(0)
else:
	print(len(max(m, key=len)))


import re
print(len(max(''.join(re.sub('[^ATCG]', ' ', input())).split(' '), key=lambda x: len(x))))


s = input()
import re
l = re.split('B|D|E|F|H|I|J|K|L|M|N|O|P|Q|R|S|U|V|W|X|Y|Z', s)
print(max([len(i) for i in l]))


import re
S = input()
l = re.findall('[ACGT]+', S)
print(max(map(len, l), default=0))


S = input()
A = B = 0
for x in S:
	if x in 'ATCG':
		A = A + 1
	else:
		B = max(A, B)
		A = 0
print(max(A, B))


S = input()
cnt = 0
res = 0
for s in S:
	if s in 'AGCT':
		cnt += 1
		res = max(res, cnt)
	else:
		cnt = 0
print(res)


S = input()
c = 0
r = 0
for s in S:
	if s in 'ATCG':
		c += 1
		r = max(r, c)
	else:
		c = 0
print(r)


str1 = input()
table = list(str1)
count = 0
ans = 0
for i in range(len(str1)):
	if table[i] == 'A' or table[i] == 'T' or table[i] == 'C' or (table[i] == 'G'):
		count += 1
		if ans < count:
			ans = count
	else:
		count = 0
print(ans)


(c, m) = (0, 0)
for i in input():
	if i in 'AGCT':
		c += 1
	else:
		if c > m:
			m = c
		c = 0
if c > m:
	m = c
print(m)


import re
regex = '[A|C|G|T]+'
s = input()
mo = re.findall(regex, s)
print(len(max(mo, key=len)) if mo != [] else 0)


import re
print(max([0] + [len(x) for x in re.findall('[ATGC]+', input())]))


s = input()
acgt = ['A', 'C', 'G', 'T']
i = 0
max_ans = 0
curr_ans = 0
while i < len(s):
	if s[i] in acgt:
		curr_ans += 1
	else:
		max_ans = max(max_ans, curr_ans)
		curr_ans = 0
	i += 1
max_ans = max(max_ans, curr_ans)
print(max_ans)


import re
S = input()
s = re.split('[^AGCT]', S)
x = max(s, key=len)
print(len(x))


import re
S = input()
ans = sorted(re.findall('[AGCT]*', S), reverse=True, key=len)
print(len(ans[0]))


S = input()
l = len(S)
answer = 0
for i in range(l):
	for j in reversed(range(i + 1, l + 1)):
		T = S[i:j]
		T_1 = T.replace('A', '').replace('C', '').replace('G', '').replace('T', '')
		if len(T_1) == 0:
			pri = j - i
			if pri > answer:
				answer = pri
print(answer)


x = 0
ans = 0
for i in input():
	if not i in 'ACGT':
		x = 0
	else:
		x += 1
		ans = max(ans, x)
print(ans)


s = input()
ans = 0
cu = 0
for c in s:
	if c in 'ACGT':
		cu += 1
	else:
		cu = 0
	ans = max(ans, cu)
print(ans)


s = input()
x = 0
y = 0
for i in range(len(s)):
	if s[i] in ['A', 'T', 'C', 'G']:
		y += 1
		x = max(x, y)
	else:
		y = 0
print(x)


import re
print(len(max(re.findall('[ACGT]*', input()), key=len)))


import re
s = input()
result = re.findall('[ACGT]*', s)
ans = max(map(len, result))
print(ans)


items = ['A', 'C', 'G', 'T']

def max(a, b):
	return a if a > b else b
x = 0
y = 0
for c in list(input()):
	if c in items:
		y += 1
		x = max(x, y)
	else:
		y = 0
print(x)


s = input()
(tmp, ans) = (0, 0)
for i in range(len(s)):
	for j in range(i, len(s)):
		if all(('AGCT'.count(h) == 1 for h in s[i:j + 1])):
			ans = max(ans, j - i + 1)
print(ans)


s = input()
ans = 0
cnt = 0
for ss in s:
	if ss in 'ATGC':
		cnt += 1
	else:
		ans = max(ans, cnt)
		cnt = 0
print(max(ans, cnt))


import re
S = str(input())
acgt = re.compile('[A,C,G,T]*')
s = re.findall(acgt, S)
print(max(map(len, s)))


c = t = 0
for s in input():
	if s in 'ACGT':
		t += 1
	else:
		c = max(c, t)
		t = 0
print(max(c, t))


S = input()
ans = 0
l = 0
for c in S:
	if c in 'ATCG':
		l += 1
		ans = max(ans, l)
	else:
		l = 0
print(ans)


s = input()
maxlen = 0
for i in range(len(s)):
	for j in range(1, len(s) + 1):
		t = s[i:j]
		if all([c in 'ACGT' for c in s[i:j]]):
			maxlen = max(maxlen, j - i)
print(maxlen)


import re
s = input()
ms = re.findall('[ACGT]*', s)
ma = 0
for m in ms:
	ma = max(ma, len(m))
print(ma)


import re
S = input()
m = re.findall('[ATCG]+', S)
i = 0
for x in m:
	if i < len(x):
		i = len(x)
print(i)


S = list(input())
temp = 0
ans = 0
letter = ['A', 'T', 'C', 'G']
for (i, val) in enumerate(S):
	if val in letter:
		temp += 1
	else:
		if ans < temp:
			ans = temp
		temp = 0
if ans < temp:
	ans = temp
print(ans)


s = input()
char = 'ACGT'
now = 0
ans = 0
for i in s:
	if i in char:
		now += 1
	else:
		now = 0
	ans = max(ans, now)
print(ans)


(a, b) = (0, 0)
for i in input() + 'Z':
	if i in ['A', 'C', 'G', 'T']:
		a += 1
	else:
		b = max(b, a)
		a = 0
print(b)


def judge(c):
	if c == 'A' or c == 'G' or c == 'C' or (c == 'T'):
		return True
	else:
		return False
s = input()
ans = 0
for i in range(0, len(s)):
	for j in range(i + 1, len(s) + 1):
		ok = True
		for k in range(i, j):
			if not judge(s[k]):
				ok = False
		if ok:
			ans = max(ans, j - i)
print(ans)


a = input() + 'a'
num = 0
b = []
for i in a:
	if i in 'ATGC':
		num += 1
	else:
		b.append(num)
		num = 0
print(max(b))


import re
S = input()
strings = re.findall('[ACGT]*', S)
print(max(map(len, strings)))


s = input()
(ma, cnt) = (0, 0)
for i in range(len(s)):
	if s[i] in ['A', 'C', 'G', 'T']:
		cnt += 1
		ma = max(ma, cnt)
	else:
		cnt = 0
print(ma)


print(len(max(''.join((str(int(c in {'A', 'T', 'G', 'C'})) for c in input())).split('0'))))


s = input()
dp = [0] * (len(s) + 1)
for (i, x) in enumerate(s):
	if x in 'ACGT':
		dp[i + 1] = dp[i] + 1
print(max(dp))


S = input()
l = len(S)
ACGT = ['A', 'G', 'C', 'T']
count = 0
ans = []
for i in range(l):
	if S[i] in ACGT:
		count += 1
		ans.append(count)
	else:
		ans.append(count)
		count = 0
print(max(ans))


S = input()
S = S.replace('A', 'a')
S = S.replace('T', 'a')
S = S.replace('C', 'a')
S = S.replace('G', 'a')
ans = 0
x = 0
for i in range(len(S)):
	if S[i] == 'a':
		x += 1
	else:
		if ans < x:
			ans = x
		x = 0
if ans < x:
	ans = x
print(ans)


S = input()
count = 0

def rec(n):
	if n >= len(S):
		return 0
	if S[n] == 'A' or S[n] == 'C' or S[n] == 'G' or (S[n] == 'T'):
		return rec(n + 1) + 1
	else:
		return 0
for i in range(len(S)):
	c = rec(i)
	count = max(count, c)
print(count)


s = input()
tmp = 0
ans = 0
for i in s:
	if i in ['A', 'T', 'G', 'C']:
		tmp += 1
		ans = max(ans, tmp)
	else:
		tmp = 0
print(ans)


import re
S = input()
num_list = [len(s) for s in re.split('[^ATCG]', S)]
print(max(num_list))


import re
S = input()
result = re.split('[^ATGC]', S)
print(max([len(i) for i in result]))


s = input()
a = 0
n = 0
for c in s:
	if c in 'ACGT':
		n += 1
	else:
		n = 0
	a = max(a, n)
print(a)


import re
S = re.findall('[ACGT]*', input())
print(max([len(s) for s in S]))


S = input()
S = ''.join((s if s in 'ACGT' else ' ' for s in S))
m = max((len(s) for s in S.split()), default=0)
print(m)


import re
s = input()
m = re.findall('[ACGT]*', s)
print(max([len(i) for i in m]))


import re
S = input()
print(len(max(re.findall('[ACTG]+', S), key=len, default='')))


s = list(input())
n = len(s)
ans = 0
for i in range(n):
	if s[i] in ['A', 'G', 'C', 'T']:
		s[i] = 'a'
for i in range(n):
	for j in range(i, n):
		flag = True
		for k in range(i, j + 1):
			if s[k] != 'a':
				flag = False
		if flag:
			ans = max([ans, j - i + 1])
print(ans)


import re
S = input()
S = re.sub('[^ACGT]', '_', S)
S = S.split('_')
ans = 0
for s in S:
	ans = max(ans, len(s))
print(ans)


import re
print(max((len(s) for s in re.findall('[ATGC]*', input()))))


import re
s = input()
ans = max(map(len, re.findall('[AGCT]+', s)), default=0)
print(ans)


import re
S = input()
S = re.split('[^ACGT]', S)
maxlen = max((len(s) for s in S))
print(maxlen)


import re
print(max(map(len, re.split('[BDEFHIJKLMNOPQRSUVWXYZ]', input()))))


moji = str(input())
ans = 0
cans = 0
correct = ['A', 'C', 'G', 'T']
for i in range(len(moji)):
	if moji[i] in correct:
		cans += 1
		if cans > ans:
			ans = cans
	else:
		if cans > ans:
			ans = cans
		cans = 0
print(ans)


print(max([len(_) for _ in ''.join([_ if _ in 'ACGT' else '_' for _ in str(input())]).split('_')]))


S = str(input())
ans = 0
for i in range(len(S)):
	for j in range(len(S)):
		cnt = 0
		flag = True
		for k in S[i:j + 1]:
			if k == 'A' or k == 'C' or k == 'G' or (k == 'T'):
				cnt += 1
			else:
				flag = False
		if flag:
			ans = max(ans, cnt)
print(ans)


S = input()
l = 0
max_l = 0
for i in S:
	if i in 'ATCG':
		l += 1
	else:
		l = 0
	if l > max_l:
		max_l = l
print(max_l)


import re
print(max((len(i) for i in re.split('[^ACTG]', input()))))


remove = ['A', 'C', 'G', 'T']
s = input()
cnt = [0] * 10
j = 0
for i in range(len(s)):
	if s[i] in remove:
		cnt[j] += 1
	else:
		j += 1
print(max(cnt))


import re
print(sorted([len(s) for s in re.split('[^ATGC]', input())], reverse=True)[0])


import re
S = re.split('B|D|E|F|[H-S]|[U-Z]', input())
len_S = [len(x) for x in S]
print(max(len_S))


s = 0
n = 0
for i in list(input()):
	if i in {'A', 'T', 'C', 'G'}:
		n += 1
	else:
		n = 0
	s = max(s, n)
print(s)


S = str(input())
le = len(S)
cnt = 0
Ans = 0
for i in range(le):
	if S[i] in 'A' or S[i] in 'C' or S[i] in 'G' or (S[i] in 'T'):
		cnt += 1
		if Ans < cnt:
			Ans = cnt
	else:
		cnt = 0
print(Ans)


import re
print(max(list(map(len, re.compile('[A|G|C|T]*').findall(input())))))


s = input()
l = 0
acc = 0
for c in s:
	if c in 'ACGT':
		acc += 1
		l = max(l, acc)
	else:
		acc = 0
print(l)


S = input()
T = []
for i in range(len(S)):
	s = S[i]
	if s == 'A' or s == 'T' or s == 'C' or (s == 'G'):
		T.append(0)
	else:
		T.append(1)
point = [0] * (len(S) + 1)
for i in range(len(S)):
	if T[i] == 0:
		point[i + 1] = point[i] + 1
	else:
		point[i + 1] = 0
print(max(point))


S = input()
L = len(S)
ans = 0
for i in range(L):
	c = 0
	for s in S[i:]:
		if s in ['A', 'C', 'G', 'T']:
			c += 1
		else:
			break
	ans = max(ans, c)
print(ans)


b = input()
(a, a_cur) = (0, 0)
for c in b:
	if c in 'ACGT':
		a_cur += 1
	else:
		a_cur = 0
	a = max(a, a_cur)
print(a)


s = input()
data = ['A', 'T', 'G', 'C']
ans = 0
for i in range(len(s)):
	for j in range(i, len(s)):
		if s[j] not in data:
			ans = max(ans, j - i)
			break
		elif j == len(s) - 1:
			ans = max(ans, len(s) - i)
print(ans)


import re
s = input()
m = [len(p.group(0)) for p in re.finditer('[ACGT]+', s)]
print(max(m + [0]))


max = c = 0
for s in input():
	if s in {'A', 'T', 'G', 'C'}:
		c += 1
	else:
		c = 0
	max = (c, max)[max > c]
print(max)


S = input()
lst = ['A', 'C', 'G', 'T']
count = 0
top = 0
for i in S:
	if i in lst:
		count += 1
	else:
		if count > top:
			top = count
		count = 0
if count > top:
	top = count
print(top)


import re

def answer(s: str) -> int:
	pattern = '[ACTG]+'
	result = re.findall(pattern, s)
	if not result:
		return 0
	return len(max(result, key=len))

def main():
	s = input()
	print(answer(s))

def __starting_point():
	main()
__starting_point()


import re
S = input()
print(max((len(s) for s in re.split('[^AGCT]', S))))


S = input()
(a, b) = (0, 0)
for s in S:
	if s in 'ATGC':
		a += 1
	else:
		a = 0
	b = max(b, a)
print(b)


L = ['A', 'C', 'G', 'T']
s = input()
cnt = [0] * len(s)
for i in range(len(s)):
	for j in range(i, len(s)):
		if s[j] in L:
			cnt[i] += 1
		else:
			break
print(max(cnt))


import re
print(max(map(len, re.split('[^ACTG]', input()))))


s = input()
c = 0
m = 0
for e in s:
	if e in 'ACGT':
		c += 1
	else:
		if c > m:
			m = c
		c = 0
if c > m:
	m = c
print(m)


S = input()
t = ''.join((c if c in 'ACGT' else ' ' for c in S))
print(max(map(len, t.split(' '))))


X = str(input())
N = len(X)
ans = 0
count = 0
for i in range(N):
	if X[i] == 'A' or X[i] == 'C' or X[i] == 'G' or (X[i] == 'T'):
		count += 1
	else:
		ans = max(ans, count)
		count = 0
else:
	ans = max(ans, count)
print(ans)


s = input()
a = ''
b = 0
for i in s:
	if i in 'ACGT':
		a += i
		if b < len(a):
			b = len(a)
	else:
		a = ''
print(b)


import re
pattern = '[^ACGT]'
S = input()
ans = max(map(len, re.split(pattern, S)))
print(ans)


print(max([len(s) for s in ''.join(['1' if s in ['A', 'C', 'G', 'T'] else '0' for s in input()]).split('0')]))


s = input()
ls = len(s)
cnt = 0
ma = 0
for i in range(ls):
	if s[i] in 'ACGT':
		cnt += 1
	else:
		ma = max(ma, cnt)
		cnt = 0
ma = max(ma, cnt)
print(ma)


import re
sin = input()
match = re.findall('[ACTG]+', sin)
m_len = [len(m) for m in match]
print(max(m_len if m_len else '0'))


S = input()
tmp = 0
ans = 0
for s in S:
	if s in 'ACGT':
		tmp += 1
	else:
		tmp = 0
	ans = max(ans, tmp)
print(ans)


S = str(input())
N = len(S)
count = 0
saidai = 0
vernon = ['A', 'G', 'T', 'C']
for i in range(0, N):
	if vernon.count(S[i]) > 0:
		count += 1
	else:
		saidai = max(saidai, count)
		count = 0
saidai = max(saidai, count)
print(saidai)


import re
s = input()
results = re.findall('[ACGT]*', s)
print(max([len(r) for r in results]))


S = input()
h = ''.join(['1' if s in 'ATCG' else '0' for s in S])
print(max([c.count('1') for c in h.split('0')]))


s = input()
l = [0] * 10
i = 0
for c in s:
	if c in ['A', 'C', 'G', 'T']:
		l[i] += 1
	else:
		i += 1
print(max(l))


import re
s = input()
res = re.findall('[ATGC]+', s)
ans = 0
for e in res:
	ans = max(ans, len(e))
print(ans)


S = str(input())
count = 0
data = []
for i in range(len(S)):
	if S[i] == 'A' or S[i] == 'T' or S[i] == 'C' or (S[i] == 'G'):
		count += 1
	else:
		data.append(count)
		count = 0
data.append(count)
print(max(data))


p = 0
m = 0
for c in input():
	p += 1
	if not c in 'ATGC':
		p = 0
	m = max(m, p)
print(m)


S = input()
ct = 0
ctM = [0]
for i in range(len(S)):
	if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or (S[i] == 'T'):
		ct += 1
		if i == len(S) - 1:
			ctM.append(ct)
	else:
		ctM.append(ct)
		ct = 0
print(max(ctM))


S = input()
ans = 0
cnt = 0
for i in S:
	if i in ['A', 'C', 'G', 'T']:
		cnt += 1
		ans = max(ans, cnt)
	else:
		cnt = 0
print(ans)


a = input()
b = 0
c = ('A', 'C', 'G', 'T')
d = 0
for i in range(len(a)):
	if a[i] in c:
		b += 1
		if b > d:
			d = b
	else:
		b = 0
print(d)


import re
s = input()
l = [len(s) for s in re.findall('[ACGT]+', s)]
print(0 if len(l) == 0 else max(l))


import re
s = input()
a = re.split('[^ATGC]', s)
mx = max(map(len, a))
print(mx)


import re
pattern = re.compile('[ACGT]+')
S = input()
print(len(max(re.findall(pattern, S), key=len, default='')))


s = input()
ans = 0
m = 0
for i in s:
	if i in 'ACGT':
		m += 1
		if m > ans:
			ans = m
	else:
		m = 0
print(ans)


import re
S = str(input())
sub = re.findall('[ACGT]*', S)
sub = [len(i) for i in sub]
print(max(sub))


a = 0
b = 0
for s in input():
	if s in ['A', 'C', 'G', 'T']:
		b += 1
	else:
		b = 0
	a = max(a, b)
print(a)


import re
data = input()
t = re.split('[^ACGT]+', data)
t.sort(key=len, reverse=True)
print(len(t[0]))


S = input()
S += '*'
st = 'ACGT'
(i, n) = (0, len(S))
max_len = 0
while i < n:
	j = i
	size = 0
	while S[j] in st:
		size += 1
		j += 1
	i = j + 1
	max_len = max(max_len, size)
print(max_len)


s = input()
t = 'ATGC'
ans = 0
l = 0
for x in s:
	if x in t:
		l += 1
		ans = max(ans, l)
	else:
		l = 0
print(ans)


s = input()
res = 0
c = 0
for i in range(len(s)):
	if s[i] == 'A' or s[i] == 'G' or s[i] == 'C' or (s[i] == 'T'):
		c += 1
	else:
		res = max(res, c)
		c = 0
res = max(res, c)
print(res)


s = input()
mx = 0
cnt = 0
for (i, char) in enumerate(s):
	if char in 'ACGT':
		cnt += 1
	else:
		mx = max(mx, cnt)
		cnt = 0
mx = max(cnt, mx)
print(mx)


s = input()
n = len(s)
a = [0] * n
for i in range(n):
	if s[i] in 'ATCG':
		a[i] = a[i - 1] + 1
	else:
		a[i] = 0
print(max(a))


def __starting_point():
	S = input()
	x = ['A', 'C', 'G', 'T']
	ans = 0
	now = 0
	for s in S:
		if s in x:
			now += 1
		else:
			now = 0
		ans = max(now, ans)
	print(ans)
__starting_point()


import re
s = input()
m = re.findall('([ACGT]+)', s)
print(len(max(m, key=len)) if m else 0)


import re
S = input()
S_sp = re.split('[^ACGT]', S)
ans = 0
for moji in S_sp:
	if len(moji) > ans:
		ans = len(moji)
print(ans)


S = input()
ans = cur = 0
for c in S:
	if c in 'ACGT':
		cur += 1
		ans = max(ans, cur)
	else:
		cur = 0
print(ans)


n = str(input())
pattern = 'ACGT'
(r, tmp) = (0, 0)
c = False
for s in n:
	if s in pattern:
		tmp += 1
	else:
		if r < tmp:
			r = tmp
		tmp = 0
if r < tmp:
	r = tmp
print(r)


s = input()
m = ['A', 'C', 'G', 'T']
ans = 0
t = 0
for i in range(len(s)):
	if s[i] in m:
		t += 1
	else:
		ans = max(ans, t)
		t = 0
print(max(ans, t))


s = input()
import re
sarr = re.split('[^ACTG]', s)
sarr = sorted(sarr, key=lambda x: len(x))
print(len(sarr[-1]))


S = list(input())
ans = 0
for i in range(len(S)):
	for j in range(i, len(S) + 1):
		tgt = S[i:j]
		cnt = 0
		for s in tgt:
			if s == 'A' or s == 'C' or s == 'G' or (s == 'T'):
				cnt += 1
			else:
				cnt = 0
				break
		ans = max(cnt, ans)
print(ans)


import re
S = input()
print(max(0, *map(len, re.findall('[AGCT]*', S))))


import re
print(max([0] + [len(r) for r in re.findall('[ACGT]+', input())]))


a = [0]
for i in input():
	if i in 'ACGT':
		a += [a[-1] + 1]
	else:
		a += [0]
print(max(a))


import sys
input = sys.stdin.readline

def slove():
	S = input()
	n = len(S)
	l = 0
	ans = 0
	for i in range(n):
		if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or (S[i] == 'T'):
			l += 1
		else:
			ans = max(ans, l)
			l = 0
	ans = max(ans, l)
	print(ans)

def __starting_point():
	slove()
__starting_point()


s = input()
ret = 0
now = 0
for c in s:
	if 'ATCG'.count(c) != 0:
		now += 1
	else:
		now = 0
	ret = max(now, ret)
print(ret)


S = input()
count = 0

def rec(n):
	if n >= len(S):
		return 0
	if S[n] in 'ACGT':
		return rec(n + 1) + 1
	else:
		return 0
for i in range(len(S)):
	c = rec(i)
	count = max(count, c)
print(count)


import re
s = input()
l = re.split('[^ACGT]+', s)
answer = max((len(_) for _ in l))
print(answer)


S = input()
m = k = 0
for c in S:
	if c in 'ACGT':
		k += 1
	else:
		m = max(m, k)
		k = 0
m = max(m, k)
print(m)


s = input()
m = 0
count = 0
for i in s:
	if i in ['A', 'C', 'G', 'T']:
		count += 1
	else:
		count = 0
	m = max(m, count)
print(m)


import re
S = input()
s = re.split('[BDEFHIJKLMNOPQRSUVWXYZ]', S)
print(max(map(len, s)))


s = input()
score = 0
ans = []
for i in s:
	if i in {'A', 'T', 'C', 'G'}:
		score += 1
	else:
		score = 0
	ans.append(score)
print(max(ans))


import re
print(max(map(len, re.findall('[ATGC]*', input()))))


import re
S = input()
L = re.findall('[AGCT]+', S)
LL = [len(x) for x in L]
if LL:
	print(max(LL))
else:
	print(0)


S = input()
import re
list_s = re.findall('[ACGT]*', S)
print(max(map(len, list_s)))


import re
S = input()
a = re.split('[BDEFHIJKLMNOPQRSUVWXYZ]', S)
A = []
for i in a:
	A.append(len(i))
print(max(A))


import re
s = input()
matched = re.findall('[ATGC]+', s)
res = 0
for m in matched:
	res = max(res, len(m))
print(res)


S = input()
agct = 'AGCT'
ans = 0
s = 0
for i in range(len(S)):
	cnt = 0
	if S[i] in agct:
		j = 0
		while i + j < len(S) and S[i + j] in agct:
			cnt += 1
			j += 1
		ans = max(ans, cnt)
print(ans)


import re
s = input()
matched = re.findall('[ATGC]+', s)
ans = 0
for i in matched:
	ans = max(ans, len(i))
print(ans)


import re
print(max([len(i) for i in re.findall('[ACGT]+', input())] + [0]))


import re
S = input()
T = re.findall('[ATGC]*', S)
print(len(max(T, key=len)))


import re
s = input()
result = re.sub('[^ACGT]', ',', s).split(',')
print(max([len(r) for r in result]))


s = input()
l = [0]
c = 0
for i in s:
	if i in 'ACGT':
		c += 1
	else:
		l.append(c)
		c = 0
l.append(c)
print(max(l))


import re
S = input()
match = re.findall('[ACGT]*', S)
print(max(map(len, match)))


import re
S = input()
pattern = '[AGCT]+'
print(max(map(len, re.findall(pattern, S)), default=0))


p = m = 0
for c in input():
	p = -~p * (c in 'ATGC')
	m = max(m, p)
print(m)


import re
s = re.split('[^ACGT]', input())
a = []
for i in range(len(s)):
	a.append(len(s[i]))
print(max(a))


S = [int(c in 'ACGT') for c in input()]
for i in range(1, len(S)):
	S[i] = (S[i - 1] + S[i]) * S[i]
print(max(S))


M = L = 0
for i in input():
	if i in 'ATCG':
		L += 1
		M = max(M, L)
	else:
		L = 0
print(M)


s = input()
k = 0
m = 0
for z in s:
	if z in 'ACGT':
		k += 1
		if m < k:
			m = k
	else:
		k = 0
print(m)


S = input()
L = ['A', 'C', 'G', 'T']
ans = 0
x = 0
for i in S:
	if i in L:
		x += 1
	else:
		x = 0
	ans = max(x, ans)
print(ans)


ans = [0]
acgt = 'ACGT'
for s in input():
	if s in acgt:
		ans[0] += 1
	else:
		ans.insert(0, 0)
print(max(ans))


s = input()
tmp = 0
length = []
for i in range(len(s)):
	if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or (s[i] == 'T'):
		tmp += 1
		if i == len(s) - 1:
			length.append(tmp)
	else:
		length.append(tmp)
		tmp = 0
print(max(length))


import re
S = input()
S = map(len, re.sub('[^ACGT]', ',', S).split(','))
print(max(S))


s = input()
ans = 0
for i in range(len(s)):
	for j in range(i, len(s)):
		if all(('ACGT'.count(c) == 1 for c in s[i:j + 1])):
			ans = max(ans, j - i + 1)
print(ans)


S = input()
d = ['A', 'T', 'C', 'G']
l = len(S)
acgt = []
a = ''
for i in range(l):
	if S[i] in d:
		a = a + S[i]
		if i == l - 1:
			acgt.append(a)
	else:
		acgt.append(a)
		a = ''
max = 0
for a in acgt:
	if len(a) > max:
		max = len(a)
print(max)


s = input()
ans = 0
ansk = 0
for i in range(len(s)):
	if s[i] in 'ACGT':
		ansk += 1
		ans = max(ans, ansk)
	else:
		ansk = 0
print(ans)


import re
H = re.findall('[ACGT]+', input())
print(len(max(H, key=lambda x: len(x))) if H else 0)


s = input()
l = len(s)
max_l = 0
count = 0
lst = ['A', 'C', 'G', 'T']
for i in range(l):
	if s[i] in lst:
		count += 1
		if count > max_l:
			max_l = count
	else:
		count = 0
print(max_l)


import re
s = input()
l = re.findall('[ACGT]*', s)
print(len(max(l, key=len)))


s = input() + 'Z'
ans = 0
t_ans = 0
for i in s:
	if i in 'ATGC':
		t_ans += 1
	else:
		ans = max(t_ans, ans)
		t_ans = 0
print(ans)


a = ''.join([i if i in ['A', 'C', 'G', 'T'] else ' ' for i in input()])
print(len(max(a.split() + [''], key=len)))


import re
s = input()
s = re.split('[^ACGT]', s)
print(max([len(i) for i in s]))


print(max(map(lambda x: len(x), ''.join([_ if _ in 'ACGT' else '_' for _ in str(input())]).split('_'))))


import re
print(max((len(s) for s in re.split('[^ATGC]+', input()))))


s = input()
mm = 0
cc = 0
for i in s:
	if i in ['A', 'C', 'T', 'G']:
		cc += 1
	else:
		mm = max(mm, cc)
		cc = 0
mm = max(mm, cc)
print(mm)


import re
S = input()
match = re.findall('[AGCT]+', S)
if len(match) == 0:
	print(0)
else:
	print(max((len(s) for s in match)))


acgt = ['A', 'C', 'G', 'T']
S = input()
count = 0
max = 0
for i in S:
	if i in acgt:
		count += 1
	elif count > max:
		max = count
		count = 0
if count > max:
	max = count
	count = 0
print(max)


import re
str = input()
arr = re.split('[^AGCT]', str)
m = 0
for part in arr:
	m = max(m, len(part))
print(m)