Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. 

Chef is instructor of the famous course "Introduction to Algorithms" in a famous univerisity. There are n students in his class. There is not enough space in the class room, so students sit in a long hallway in a linear fashion.

One day Chef was late to class. As a result, some of the students have formed pairs and are talking to each other, while the others are busy studying. This information is given to you by a string s of length n, consisting of characters '*', ', where '*' denotes that the student is studying, '>' denotes that the corresponding student is talking to the student to the right, and 'For example, consider a sample configuration of students - *>>< is also not a valid configuration, as students 2 and 3 are talking to each other, so student 1 won't be able to talk to student 2.

When the students see their teacher coming, those who were talking get afraid and immediately turn around, i.e. students talking to left have now turned to the right, and the one talking to right have turned to the left. When Chef sees two students facing each other, he will assume that they were talking. A student who is busy studying will continue doing so. Chef will call each pair of students who were talking and punish them. Can you find out how many pairs of students will get punished?

For example, in case *>*>, Chef sees that student 2 and 3 are talking to each other and they will be punished.

------ Input ------ 

The first line of the input contains an integer T denoting the number of the test cases.
Each test case contains a string s denoting the activities of students before students see Chef entering the class.

------ Output ------ 

For each test case, output a single integer denoting the number of pairs of students that will be punished.

------ Constraints ------ 

1 ≤ T ≤ 10
1 ≤ |s| ≤ 10^{5}

------ Subtasks ------ 

Subtask #1: (30 points)

1 ≤ T ≤ 10
1 ≤ |s| ≤ 10^{5}
No student is studying.
 
Subtask #2: (70 points)

Original Constraints.

----- Sample Input 1 ------ 
4
><
*><*
><
*><*
----- Sample Output 1 ------ 
0
0
1
2
----- explanation 1 ------ 
Example case 1. The updated configuration will be . No students are talking to each other, so no one will be punished.
Example case 2 and 3. These examples are already explained in the problem statement.

Difficulty: EASY
Tags: Constructive algorithms

Implementation

Ad-hoc

Starter code:

Solutions:
for _ in range(int(input())):
	print(input().count('<>'))


for t in range(int(input())):
	L = input()
	r = 0
	for i in range(len(L) - 1):
		if L[i] == '<':
			if L[i + 1] == '>':
				r += 1
	print(r)


t = int(input())
for i in range(t):
	y = input()
	print(y.count('<>'))


for i in range(int(input())):
	n = input()
	print(n.count('<>'))


t = int(input())
for i in range(t):
	s = list(input())
	c = 0
	for i in range(len(s) - 1):
		if s[i] == '<' and s[i + 1] == '>':
			c += 1
	print(c)


for i in range(int(input())):
	s = input()
	s = s.replace('<', '|')
	s = s.replace('>', '<')
	s = s.replace('|', '>')
	print(s.count('><'))


for _ in range(int(input())):
	s = input()
	count = 0
	for i in range(len(s) - 1):
		if s[i] == '<' and s[i + 1] == '>':
			count += 1
	print(count)


T = int(input())
for i in range(T):
	S = input()
	count = 0
	for i in range(len(S) - 1):
		if S[i] == '<' and S[i + 1] == '>':
			count = count + 1
	print(count)


for _ in range(int(input())):
	l = list(input())
	for i in range(0, len(l)):
		if l[i] == '*':
			continue
		elif l[i] == '>':
			l[i] = '<'
		else:
			l[i] = '>'
	s = ''
	for i in l:
		s += i
	print(s.count('><'))


for i in range(int(input())):
	Str = input()
	newStr = ''
	for i in Str:
		if i == '<':
			newStr += '>'
		elif i == '>':
			newStr += '<'
		else:
			newStr += i
	print(newStr.count('><'))


for _ in range(int(input())):
	s = input()
	s = list(s)
	n = len(s)
	for i in range(n):
		if s[i] == '>':
			s[i] = '<'
		elif s[i] == '<':
			s[i] = '>'
	c = 0
	for i in range(n - 1):
		if s[i] == '>' and s[i + 1] == '<':
			c += 1
	print(c)


s = int(input())
for i in range(s):
	a = input()
	ans = 0
	for j in range(len(a) - 1):
		if a[j] == '<':
			if a[j + 1] == '>':
				ans += 1
	print(ans)


t = int(input())
for i in range(t):
	s = input()
	k = s.count('<>')
	print(k)


for t in range(int(input())):
	print(str(input()).count('<>'))


for i in range(int(input())):
	s = input()
	c = s.count('<>')
	print(c)


t = int(input())
for i in range(t):
	s = input()
	v = ''
	for j in s:
		if j == '>':
			v = v + '<'
		elif j == '<':
			v = v + '>'
	c = s.count('<>')
	print(c)


t = int(input())
for i in range(t):
	a = input()
	c = a.count('<>')
	print(c)


cases = int(input())
for _ in range(cases):
	s = input()
	cnt = s.count('<>')
	print(cnt)


t = int(input())
for i in range(t):
	s = input()
	l = len(s)
	i = 0
	c = 0
	while i < l - 1:
		if s[i] == '<' and s[i + 1] == '>':
			c = c + 1
			i = i + 2
		else:
			i = i + 1
	print(c)


T = int(input())
for i in range(T):
	before = input()
	after = ''
	count = 0
	for j in range(len(before)):
		if before[j] == '<':
			after = after + '>'
		elif before[j] == '>':
			after = after + '<'
		else:
			after = after + '*'
	for k in range(len(before) - 1):
		if after[k] == '>' and after[k + 1] == '<':
			count = count + 1
	print(count)


t = int(input())
for j in range(t):
	s = input()
	count = 0
	for k in range(len(s) - 1):
		if s[k] == '<' and s[k + 1] == '>':
			count += 1
	print(count)


for t in range(int(input())):
	s = input()
	s = list(s)
	for i in range(len(s)):
		if s[i] == '>':
			s[i] = '<'
		elif s[i] == '<':
			s[i] = '>'
	s1 = ''.join((str(i) for i in s))
	print(s1.count('><'))


for i in range(int(input())):
	s = input()
	n = 0
	t = 0
	m = 0
	for j in range(len(list(s))):
		if s[j] == '<':
			t = j
		elif s[j] == '>':
			m = j
		else:
			t = 1
			continue
		if m - t == 1:
			n = n + 1
	print(n)


for _ in range(int(input())):
	a = input()
	if len(a) != 0:
		print(a.count('<>'))
	else:
		print(a.count('><'))


t = int(input())
while t > 0:
	s = input()
	print(s.count('<>'))
	t = t - 1


t = int(input())
for i in range(t):
	s = input()
	a = s.count('<>')
	print(a)


try:
	for _ in range(int(input())):
		S = list(input())
		for i in range(len(S)):
			if S[i] == '<':
				S[i] = '>'
			elif S[i] == '>':
				S[i] = '<'
		c = ''.join(S).count('><')
		print(c)
except:
	pass


goals = int(input())
for distractions in range(goals):
	print(input().count('<>'))


t = int(input())
for i in range(t):
	s = input()
	l = len(s)
	result = 0
	j = 0
	while j < l - 1:
		if s[j] == '<' and s[j + 1] == '>':
			result += 1
			j += 1
		j += 1
	print(result)


for __ in range(int(input())):
	flag = 0
	L = input()
	l = [L[i:i + 1] for i in range(0, len(L), 1)]
	for k in range(len(L) - 1):
		if l[k] == '<' and l[k + 1] == '>':
			flag += 1
	print(flag)


for _ in range(int(input())):
	array1 = list(input())
	rev_arr1 = []
	a = 1
	g = 0
	count = 0
	for y in array1:
		if y == '*':
			rev_arr1.append(y)
		elif y == '<':
			rev_arr1.append('>')
		else:
			rev_arr1.append('<')
	while len(rev_arr1) - 1 >= a:
		if rev_arr1[g] == '*':
			g += 1
			a += 1
			continue
		elif rev_arr1[g] == '>' and rev_arr1[g + 1] == '<':
			count += 1
			a += 1
			g += 1
		else:
			g += 1
			a += 1
			continue
	print(count)


for t in range(int(input())):
	s = input()
	l = list(s)
	for i in range(len(l)):
		if l[i] == '<':
			l[i] = '>'
		elif l[i] == '>':
			l[i] = '<'
	s = ''.join(l)
	c = 0
	for i in range(1, len(s)):
		if ord(s[i - 1]) == ord(s[i]) + 2:
			c += 1
	print(c)


T = int(input())
for i in range(T):
	s = input()
	print(s.count('<>'))


for _ in range(int(input())):
	a = input()
	b = 0
	for i in range(len(a) - 1):
		if a[i] + a[i + 1] == '<>':
			b += 1
	print(b)


r = int(input())
while r != 0:
	s = input()
	if '<>' in s:
		m = s.count('<>')
		print(m)
	else:
		print(0)
	r = r - 1


def count_punished_pairs(s):
	n = len(s)
	t = [''] * n
	for i in range(n):
		if s[i] == '*':
			t[i] = '*'
		elif s[i] == '<' and i > 0:
			t[i] = '>'
		elif s[i] == '>' and i < n - 1:
			t[i] = '<'
	punished_pairs = 0
	for i in range(n - 1):
		if t[i] == '>' and t[i + 1] == '<':
			punished_pairs += 1
	return punished_pairs
T = int(input())
for t in range(T):
	s = input().strip()
	print(count_punished_pairs(s))


for i in range(int(input())):
	x = input()
	print(x.count('<>'))