Example

Input

7
>>


Output

7
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool comp(int a, int b){ return b < a; }

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

    vector<char> lr(n+2, 0);
    vector<int> csuml(n+2,0), csumr(n+2,0);
    for(int i=1; i<=n; i++){ cin >> lr[i]; }
    for(int i=1; i<n+2; i++){
        csuml[i]=csuml[i-1];
        if(lr[i]=='>') csuml[i]++;
    }
    for(int i=n; i>=0; i--){
        csumr[i]=csumr[i+1];
        if(lr[i]=='<') csumr[i]++;
    }

    int s=1, e=n;
    int ans=0;
    while(s <= e){
        int m=(s+e)/2;
        int adjst=0;
        vector<int>::iterator it;
        if(csuml[m-1] < csumr[m+1] || (csuml[m-1]==csumr[m+1] && lr[m]=='<')){
            s=m+1;
            if(lr[m]=='>') adjst=1;
            it = lower_bound(csumr.begin(), csumr.end(), csumr[m+1]-csuml[m-1]-adjst, comp);
            ans = max(ans, (int)(it-csumr.begin())-1);
        }else{
            e=m-1;
            if(lr[m]=='<') adjst=1;
            it = upper_bound(csuml.begin(), csuml.end(), csuml[m-1]-csumr[m+1]-adjst);
            ans = max(ans, (int)(csuml.end()-it)-1);
        }
    }
    
    cout << ans << endl;
    return 0;
}