Example

Input

7
>>


Output

7
#include <iostream>
#include <string>

using namespace std;
const int MAX = 131072;

int bitl[MAX];
int bitr[MAX];

int suml(int i) {
    int s = 0;
    while (i > 0) {
        s += bitl[i];
        i -= i & -i;
    }
    return s;
}
void addl(int i, int x) {
    while (i <= MAX) {
        bitl[i] += x;
        i += i & -i;
    }
}

int sumr(int i) {
    int s = 0;
    while (i > 0) {
        s += bitr[i];
        i -= i & -i;
    }
    return s;
}
void addr(int i, int x) {
    while (i <= MAX) {
        bitr[i] += x;
        i += i & -i;
    }
}

int main(void){
    int n;
    string s;
    cin >> n >> s;
    int l=0, r=0, tl=0, tr=0;
    for (int i = 0; i < n; i++) {
        if (s[i]=='<') addl(l+1, tr);
        else addr(r+1, tl);
        
        if (s[i]=='<') l++,tl++,tr=0;
        else r++,tr++,tl=0;
    }
    
    int ans = 0, t = 0;
    tl = 0, tr = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i]=='<') {
            tl++;
            if (tr > l-tl) {
                int left_rcnt = tr-(l-tl); 
                ans = max(ans, n-(left_rcnt-1)-sumr(left_rcnt));
            }
            else {
                int left_l = tl;
                int right_l = tr;
                ans = max(ans, left_l+right_l+suml(tl+tr));
            }
        }
        else {
            tr++;
            if (l-tl >= tr) ans = max(ans, tl+tr+suml(tl+tr));
            else {
                int left_rcnt = tr-(l-tl);
                ans = max(ans, n-(left_rcnt-1)-sumr(left_rcnt));
            }
        }
    }
    cout << ans << endl;
}