program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

{function Not2Dig(line:string):string;
var i:integer;
begin
for i:=1 to Length(line)-1 do begin

end;
end;}
function Dig2Not(n:integer):string;
var res:string;
begin
case (n) of
0:res:='{}';
1:res:='{{}}';
2:res:='{{},{{}}}';
3:res:='{{},{{}},{{},{{}}}}';
4:res:='{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}}';
end;
Result:=res;
end;

var finput,foutput:textfile; line1,line2:string; i,c1,c2:integer;
begin
  assign(finput,'input.txt');
  reset(finput);
  readln(finput,line1);
  c1:=0;
  for i:=1 to Length(line1) do if line1[i]=',' then inc(c1);
  if c1>0 then c1:=c1+1;
  if Length(line1)=2 then c1:=0;
  if Length(line1)=4 then c1:=1;

  readln(finput,line2);
  c2:=0;
  for i:=1 to Length(line2) do if line2[i]=',' then inc(c2);
  if c2>0 then c2:=c2+1;
  if Length(line2)=2 then c2:=0;
  if Length(line2)=4 then c2:=1;

  assign(foutput,'output.txt');
  rewrite(foutput);
  writeln(foutput,Dig2Not(c1+c2));
  close(foutput);
end.

