#include <bits/stdc++.h>
using namespace std;
int n, a[109], dp[109][109][2];
string s;
int solve(int i, int j, int type) {
  if (i > j) return 100;
  if (dp[i][j][type] == -1) {
    if (i == j) {
      if (a[i] == type) return 0;
      return 1;
    }
    int temp = 100;
    for (int l = 0; l < j - i; l++) {
      temp = min(temp, solve(i, i + l, type) + solve(i + l + 1, j, type));
      temp = min(temp, solve(i, i + l, 1) + solve(i + l + 1, j, 0));
      temp = min(temp, solve(i, i + l, 0) + solve(i + l + 1, j, 1) + 1);
      temp = min(temp,
                 solve(i, i + l, type ^ 1) + solve(i + l + 1, j, type ^ 1) + 1);
    }
    dp[i][j][type] = temp;
  }
  return dp[i][j][type];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> s;
    if (n == 1) {
      cout << "0\n";
      continue;
    }
    for (int i = 0; i < n; i++) {
      if (s[i] == '<')
        a[i] = 0;
      else {
        a[i] = 1;
      }
    }
    memset(dp, -1, sizeof(dp));
    int ans = min(solve(0, n - 1, 0), solve(0, n - 1, 1));
    cout << ans << "\n";
  }
  return 0;
}
