Example

Input

7
>>


Output

7
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  
  string s;  
  cin >> s;

  int ans = 0;
  {
    vector<int> cumr(n, 0), cuml(n, 0);
    int sumr = 0, suml = 0;
    for ( int i = 0; i < n; i++ ) {
      if ( i ) {
	cumr[i] = cumr[i-1];
	cuml[i] = cuml[i-1];
      }
      if ( s[i] == '>' ) {
	cumr[i]++;
	sumr++;
      } else {
	cuml[i]++;
	suml++;      
      }
    }

    if ( sumr == n || suml == 0 ) ans = n;    
    for ( int i = 0; i < n; i++ ) {
      if ( s[i] == '<' ) continue;      
      int a = cumr[i];
      int b = cuml[i]+a;
      if ( b-1 == suml ) {      
	ans = max(ans, n-(int)(lower_bound(cumr.begin(), cumr.end(), 1)-cumr.begin()));
      }
      if ( b > suml ) continue;
      int c = lower_bound(cuml.begin(), cuml.end(), b)-cuml.begin();      
      ans = max(ans, c+1);
    }
    // cout << ans << endl;
  }
  {
    reverse(s.begin(), s.end());
    for ( int i = 0; i < n; i++ ) {
      if ( s[i] == '>' ) s[i] = '<';
      else s[i] = '>';      
    }
    // cout << s << endl;
    vector<int> cumr(n, 0), cuml(n, 0);
    int sumr = 0, suml = 0;
    for ( int i = 0; i < n; i++ ) {
      if ( i ) {
	cumr[i] = cumr[i-1];
	cuml[i] = cuml[i-1];
      }
      if ( s[i] == '>' ) {
	cumr[i]++;
	sumr++;
      } else {
	cuml[i]++;
	suml++;      
      }
    }

    if ( sumr == n || suml == 0 ) ans = n;    
    for ( int i = 0; i < n; i++ ) {
      if ( s[i] == '<' ) continue;      
      int a = cumr[i];
      int b = cuml[i]+a;
      if ( b-1 == suml ) {	
	ans = max(ans, n-(int)(lower_bound(cumr.begin(), cumr.end(), 1)-cumr.begin()));
      }
      if ( b > suml ) continue;
      int c = lower_bound(cuml.begin(), cuml.end(), b)-cuml.begin();
      // cout << a << " " << b << " " << i << " " << c+1 << endl;
      ans = max(ans, c+1);      
    }
  }

  cout << ans << endl;
  return 0;
}
