class Codechef
{
public static void main (String[] args) {
Scanner s=new Scanner(System.in);
int t=s.nextInt();
while(t>0) {
String str=s.next();
char[]ch=str.toCharArray();
long len=ch.length;
goal(ch,len);
t–;
}
}
public static void goal(char ch[],long len) {
long count=0;
long count1=0;
long temp=0;
for(int i=0;i<len;i++) {
if(ch[0]==('>')) {
System.out.println("0");
break;
}
else if(ch[i]==('<')) {
count++;
}
else if(ch[i]==('>') && i != 0) {
count--;
temp++;
}
if(count<0) {
break;
}
else if(count==0) {
count1=temp;
}
}
if(count1>=1) {
System.out.println(count1*2);
}
}
}