#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_2(string s, int& p, vector& buf){ if(p == (int)s.size()) return ""; if(s[p] != '(') return ""; vector res; p++; res.push_back(refine_2(s, p, buf)); p++; res.push_back(refine_2(s, p, buf)); p++; res.push_back(refine_2(s, p, buf)); rep(t,3) buf.push_back(res[0]); buf.push_back("D" + res[0] + "C" + res[1] + "B" + res[2] + "A"); return buf.back(); } string refine(string s){ int p = 0; vector buf; refine_2(s, p, buf); return *max_element(buf.begin(), buf.end()); } 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; }