from collections import * from itertools import * from functools import cache, partial from pprint import pprint import sys from typing import Any, Final try: from icecream import ic except ImportError: # Graceful fallback if IceCream isn't installed. ic = lambda *a: None if not a else (a[0] if len(a) == 1 else a) # noqa debug = partial(print, file=sys.stderr) dpprint = partial(pprint, stream=sys.stderr) sys.setrecursionlimit(10**6) MOD = 998244353 S_ = input() N = len(S_) S = [] cnt = 0 for s in S_: if s == "<" or s == ">": if cnt > 0: S.append(("=", cnt)) cnt = 0 S.append((s, 1)) else: cnt += 1 if cnt > 0: S.append(("=", cnt)) # ic(S) ans = N stack = [] for char, cnt in S: if char in ["<", ">"]: stack.append((char, cnt)) elif stack and stack[-1][0] == "=": _, cnt2 = stack.pop() stack.append(("=", cnt + cnt2)) else: stack.append(("=", cnt)) while ( len(stack) >= 3 and stack[-1][0] == ">" and stack[-2][0] == "=" and stack[-3][0] == "<" ): ans -= 2 + stack[-2][1] stack.pop() stack.pop() stack.pop() print(ans)