uses crt;
var st:char;
a,b:real;
begin
clrscr;
readln(a,b);
readln(st);
if (st='A') then writeln(2*a+b)
else if (st='C') then writeln(a+2*b)
else writeln(a+b+1/2*a+b);
readln;
end.
uses crt;
var st:char;
a,b:real;
begin
clrscr;
readln(a,b);
readln(st);
if (st='A') then writeln(2*a+b)
else if (st='C') then writeln(a+2*b)
else writeln(a+b+1/2*a+b);
readln;
end.