Example

Input

7
>>


Output

7
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);
#define readV(_v) rep(j, _v.size()) cin >> _v[j];
#define readVV(_vv) rep(i, _vv.size()) readV(_vv[i]);
#define print(_x) cout << _x << endl;

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

string rev(string s) {
    string t;
    rrep(i, s.size()) {
        t += (s[i] == '<' ? '>' : '<');
    }
    return t;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    cin >> n;
    string s;
    cin >> s;

    if (s.find(">") == string::npos || s.find("<") == string::npos) {
        cout << n << endl;
        return 0;
    }

    int ans = -1;
    rep(t, 2) {
        vi vr;
        vi vl;
        rep(i, n) {
            if (s[i] == '<') {
                vr.emplace_back(i);
            } else {
                vl.emplace_back(i);
            }
        }

        int l = 0, r = 0;
        int cl = 0, cr = 1;
        rep(i, n) {
            if (s[i] == '>') {
                if (cl < cr) {
                    assert(cl == cr - 1);
                    ans = max(ans, vr[r] + 1);
                    // l???????????????cl???1?¢???????
                    cl++;
                    // cr????¢?????????????????¢???????
                    if (r + 1 < vr.size()) {
                        r++;
                        cr++;
                    }
                } else {
                    assert(cl == cr);
                    ans = max(ans, n - vl[l]);
                    // cl???????????????l???1?????????
                    l++;
                }
            } else {
                // '<'???1?????±?????????
                if (r + 1 < vr.size()) {
                    // ?¨??????????????????°cr????????£???????????????
                    r++;
                } else {
                    // ?¨?????????????????????°1????????????
                    cr--;
                    if (cl > cr) {
                        cl--;
                        l++;
                    }
                }
            }
        }
        s = rev(s);
    }

    cout << ans << endl;

}