Problem:
Score : 300 points

Problem Statement

Given is a string S of length N-1.
Each character in S is < or >.

A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \leq i \leq N-1):

If S_i= <: a_i<a_{i+1}

If S_i= >: a_i>a_{i+1}

Find the minimum possible sum of the elements of a good sequence of N non-negative integers.

Constraints

2 \leq N \leq 5 \times 10^5

S is a string of length N-1 consisting of < and >.

Input

Input is given from Standard Input in the following format:

S

Output

Find the minimum possible sum of the elements of a good sequence of N non-negative integers.

Sample Input 1

<>>

Sample Output 1

3

a=(0,2,1,0) is a good sequence whose sum is 3.
There is no good sequence whose sum is less than 3.

Sample Input 2

<>>><<><<<<<>>><

Sample Output 2

28

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18+500
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN (int)5e5+5
#if !testing
#define cerr if(0)cout
#endif
/*
 * >< -> 0
 * >> A[i]=A[i+1]+1
 * <> A[i]=min(A[i-1],A[i+1])+1
 * << A[i]=A[i-1]+1
*/
string str; 
int dp[MAXN];
int n;
int dpdp(int x, int p){
	//db(x);
	if(~dp[x])return dp[x];
	if(x==1){
		if(str[x]=='<')return dp[x]=0;
		else return dp[x] = dpdp(x+1,x)+1;
	}
	if(x==n) {
		if(str[x-1]=='>')return dp[x]=0;
		else return dp[x] = dpdp(x-1,x)+1;
	}
	if(str[x-1]=='<') {
		if(str[x]=='<') return dp[x] = dpdp(x-1,x)+1;
		int ans=-1;
		if(p^(x-1))ans=dpdp(x-1,x)+1;
		if(p^(x+1))ans=max(ans,dpdp(x+1,x)+1);
		return dp[x]=ans;
	} else {
		if(str[x]=='<')return dp[x]=0;
		else return dp[x]=dpdp(x+1,x)+1;
	}

}
int32_t main() {
	IAMSPEED
	memset(dp,-1,sizeof dp);
	cin>>str;
	str="A"+str;
	n = str.size();
	//exit(0);
	int ans = 0;
	FOR(i,1,n)ans+=dpdp(i,-1);
	cout<<ans;
}