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
res:='{';
if (n>=0) then res:=res+'';
if (n>=1) then res:=res+'{}';
if (n>=2) then res:=res+',{{}}';
if (n>=3) then res:=res+',{{},{{}}}';
if (n>=4) then res:=res+',{{},{{}},{{},{{}}}}';
if (n>=5) then res:=res+',{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}}';
if (n>=6) then res:=res+',{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}}}';
if (n>=7) then res:=res+',{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}}}}';
if (n>=8) then begin res:=res+',{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}}},';
  res:=res+'{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}}}}}';
end;
if (n>=9) then begin res:=res+'{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},';
  res:=res+'{{},{{}}}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},';
  res:=res+'{{}}}}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},';
  res:=res+'{{}}}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}},{{},{{}},{{},{{}}},{{},{{}},{{},{{}}}}}}}}}';
end;

res:=res+'}';
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));
  //writeln(Dig2Not(9));
  //readln;
  close(foutput);
end.

