#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 5;
string a;
int cal(int s, int e) {
if (s >= a.size() || s >= e || e < 0) return 0;
else {
int op = 0, p = -1;
for (int i = s + 1; i < e; ++i) {
if (a[i] == '(') op++;
else if (a[i] == ')') op--;
if (op == 0) {
p = i;
break;
}
}
int ans1 = cal(s + 1, p);
if (p + 2 < e && a[p + 1] == '-' && a[p + 2] == '>')
return max(ans1 + 1, cal(p + 3, e - 1));
return ans1;
}
}
void solve() {
cin >> a;
a = '(' + a;
a = a + ')';
cout << cal(0, a.size() - 1);
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int tc = 1;
// cin >> tc;
while (tc--) solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGludCBsb25nIGxvbmcKY29uc3QgaW50IE4gPSAxZTYgKyA1OwoKc3RyaW5nIGE7CgppbnQgY2FsKGludCBzLCBpbnQgZSkgewoJaWYgKHMgPj0gYS5zaXplKCkgfHwgcyA+PSBlIHx8IGUgPCAwKSByZXR1cm4gMDsKCWVsc2UgewoJCWludCBvcCA9IDAsIHAgPSAtMTsKCQlmb3IgKGludCBpID0gcyArIDE7IGkgPCBlOyArK2kpIHsKCQkJaWYgKGFbaV0gPT0gJygnKSBvcCsrOwoJCQllbHNlIGlmIChhW2ldID09ICcpJykgb3AtLTsKCQkJaWYgKG9wID09IDApIHsKCQkJCXAgPSBpOwoJCQkJYnJlYWs7CgkJCX0KCQl9CgkJaW50IGFuczEgPSBjYWwocyArIDEsIHApOwoJCWlmIChwICsgMiA8IGUgJiYgYVtwICsgMV0gPT0gJy0nICYmIGFbcCArIDJdID09ICc+JykKCQkJcmV0dXJuIG1heChhbnMxICsgMSwgY2FsKHAgKyAzLCBlIC0gMSkpOwoJCXJldHVybiBhbnMxOwoJfQp9Cgp2b2lkIHNvbHZlKCkgewoJY2luID4+IGE7CglhID0gJygnICsgYTsKCWEgPSBhICsgJyknOwoJY291dCA8PCBjYWwoMCwgYS5zaXplKCkgLSAxKTsKfQoKc2lnbmVkIG1haW4oKSB7CgljaW4udGllKDApIC0+IHN5bmNfd2l0aF9zdGRpbygwKTsKCWludCB0YyA9IDE7CgkvLyBjaW4gPj4gdGM7Cgl3aGlsZSAodGMtLSkgc29sdmUoKTsKCXJldHVybiAwOwp9