#include #include #include #include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; int main(){ string H; cin >> H; vector L; vector R; auto dfs = [&](auto& dfs, int& pos) -> int { if(pos == (int)H.size() || H[pos] != '(') return -1; int x = L.size(); L.push_back(-1); R.push_back(-1); pos++; L[x] = dfs(dfs, pos); pos++; R[x] = dfs(dfs, pos); return x; }; int xxxpos = 0; int root = dfs(dfs, xxxpos); auto dp = [&](auto& dp, int pos) -> int { if(pos == -1) return -1; int rdp = dp(dp, R[pos]); if(abs(rdp) >= 2) return rdp; if(L[pos] < 0) return -rdp; int tmp = L[pos] * rdp; if(abs(tmp) <= 1) tmp *= 2; return tmp; }; int ans = dp(dp, root); if(ans > 1) ans = 1; if(ans < -1) ans = -1; if(ans == 1) cout << 0 << endl; if(ans == -1) cout << 1 << endl; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;