#include <iostream>
#include <string.h>
using namespace std;


char buf1[1000];
char buf2[1000];
char* s0="{}";
char* s1="{{}}";

char* int2str(int i)
{
	if(i==0)
		return s0;
	if(i==1)
		return s1;
	char* res=new char[1000];
	char* s1="{";
	char* s2="}";
	char* s3=",";
	res[0]='\0';
	res = strcat(res, s1);
	int j;
	for(j=0;j<i-1;j++)
	{
		res = strcat(res, int2str(j));
		res = strcat(res, s3);
	}
	res = strcat(res, int2str(j));
	res = strcat(res, s2);
	return res;
}

int main()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	scanf("%s", &buf1);
	scanf("%s", &buf2);
	int n=strlen(buf1), i=0;
	for(i=n-1;i>=0;i--)
		if(buf1[i]!='}')
			break;
	int num1=n-i-2;
	n=strlen(buf2);
	i=0;
	for(i=n-1;i>=0;i--)
		if(buf2[i]!='}')
			break;
	int num2=n-i-2;
	cout << int2str(num1+num2);
	return 0;
}