#include <fstream>
#include <string>

using namespace std;

int stack[10000+1];
int h = 0;

int read(string &st) {
	int r=0,mr=0;
	for ( int i = 0; i < st.length(); i++) {
		if( st[i]=='{') r++;
		else if( st[i]=='}') r--;
		if (r>mr) mr = r;
	}
		
	return (mr-1);
}

void write(int x, ofstream&out) {
	out << '{';
	if(x){ 
		out<<"{}";
		for(int i = 1; i<x; i++) {
			out<<',';
			write(i,out);
		}
	}
	out << '}';
}

int main () {
	ifstream in;
	in.open("input.txt");

	ofstream out;
	out.open("output.txt");

	string st;

	in >> st;
	int x1 = read(st);
	in >> st;
	int x2 = read(st);

	write(x1+x2,out);
	
	in.close();
	out.close();
}