// Josh Linge
// 2/21/2017
// Solution to 2017 FHSPS Playoff Question: Game

import java.util.Scanner;

public class game_linge {

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    
    int testCases = in.nextInt();
    
    // Process cases.
    for(int cur = 0; cur < testCases; ++cur) {
      String line = in.next();

      int level = 0;
      int max = 0;
      
      // Go through the string.
      for(char c : line.toCharArray()) {
      	
      	// Count as necessary and update max, just for up down characters.
        if(c == 'v') {
          ++level;
          max = Math.max(level, max);
        } else if(c == '^') {
          --level;
        }
      }
      
      // Print result.
      System.out.println(max);
    }
    
    in.close();
  }
}
