// Arup Guha
// 2/10/2017
// Solution to 2017 FHSPS Playoff Problem: Ground Game

import java.util.*;

public class game {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=0; loop<numCases; loop++) {

			// Get basic parameters.
			String s = stdin.next();

			int cur = 0, res = 0;

			// Go through directions, update current level and max if necessary.
			for (int i=0; i<s.length(); i++) {
				if (s.charAt(i) == 'v') cur++;
				if (s.charAt(i) == '^') cur--;
				res = Math.max(res, cur);
			}

			// Output the result.
			System.out.println(res);

		}
	}
}