// Justin Almazan
// 6/25/2025
// Solution to 2025 CS SI UCF Contest 3 Problem: Methodic Multiplication
// https://open.kattis.com/problems/methodicmultiplication

#include <bits/stdc++.h>
using namespace std;

string s1, s2;

string solve() {
    
    // Count number of occurences of '(' in both strings
    int n1 = count(s1.begin(), s1.end(), '(');
    int n2 = count(s2.begin(), s2.end(), '(');

    // Multiply them together
    int n = n1 * n2;

    // Create answer string using that many nested parentheses
    string res = "";
    
    // Open parentheses
    for (int i = 0; i < n; i++) 
        res += "S(";
    
    // Central zero
    res += "0";
    
    // Close the parentheses
    for (int i = 0; i < n; i++) 
        res += ")";
    
    // Return answer
    return res;
}

int main() {

    // Get input strings
    cin >> s1 >> s2;

    // Answer
    cout << solve() << endl;
    
    return 0;
}