#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string str;
    cin >> str;
    if (str[0] == '<' && str[n - 1] == '>') {
      int i = 0, a = 0, b = 0, j = n - 1;
      while (str[i] == '<') {
        a++;
        i++;
      }
      while (str[j] == '>') {
        b++;
        j--;
      }
      if (a > b)
        cout << "K" << b << endl;
      else
        cout << a << endl;
    } else
      cout << 0 << endl;
  }
}
