#include using namespace std; int main() { string S; cin >> S; vector lt; vector gt; vector eq; int N = S.size(); for (int i = 0; i < N; i++) { if (S[i] == '<') { lt.push_back(i); } if (S[i] == '>') { gt.push_back(i); } if (S[i] == '=') { eq.push_back(i); } } vector lt_tmp = lt; reverse(lt.begin(), lt.end()); int current_place = lt[0] + 1; int lt_N = lt.size(); int ans = N; for (int i = 0; i < lt_N; i++) { auto it_gt = lower_bound(gt.begin(), gt.end(), current_place); auto it_eq = lower_bound(eq.begin(), eq.end(), current_place); auto it_lt = lower_bound(lt_tmp.begin(), lt_tmp.end(), current_place); if (it_gt == gt.end() || it_eq == eq.end()) { if (i != lt_N - 1) { current_place = lt[i + 1] + 1; } continue; // 後で変更 } int lt_place; if (it_lt == lt.end()) { lt_place = 1e9; } else { lt_place = *it_lt; } int gt_place = *it_gt; int eq_place = *it_eq; if (!(eq_place < gt_place && gt_place < lt_place)) //=><の順番では無ければ { if (i != lt_N - 1) { current_place = lt[i + 1] + 1; } continue; // 後で変更 } ans -= gt_place - eq_place + 2; auto next_lt = lower_bound(lt_tmp.begin(), lt_tmp.end(), lt[i]); auto next_gt = upper_bound(gt.begin(), gt.end(), gt_place); if (next_lt == lt.begin() || next_gt == gt.end()) { if (i != lt_N - 1) { current_place = lt[i + 1] + 1; } } else // 現在の<>が内側の<>だった場合 { current_place = gt_place + 1; } } cout << ans; }