#include #include #include #include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; string refine(string s){ vector st; string Q; auto check3 = [&](){ while(st.size() && st.back() == 2){ Q.push_back('A'); st.pop_back(); } }; for(char c : s){ if(c == '('){ st.push_back(0); Q += "D"; } if(c == '|'){ check3(); st.back()++; Q += "C"; } if(c == ')'){ check3(); st.back()++; Q += "B"; } } check3(); return Q; } int main(){ string chars = ")|("; string T0, T1; cin >> T0 >> T1; T0 = refine(T0); T1 = refine(T1); if(T0 < T1) cout << "1\n"; else cout << "0\n"; return 0; }