var
s:ansistring;
n,i,l:longint;
a:Array[0..100000]of longint;
f:array[0..2000,1..3]of longint;
begin
assign(input,'fbi.in'); reset(input);
assign(output,'fbi.out'); rewrite(output);
readln(s);
l:=length(s);
for i:=1 to l do
case s[i] of
'F':begin
inc(n);
a[n]:=1;
end;
'B':begin
inc(n);
a[n]:=2;
end;
'I':begin
inc(n);
a[n]:=3;
end;
end;
for i:=1 to n do
begin
f[i,1]:=f[i-1,1];
if a[i]=1 then inc(f[i,1]);
end;
for i:=1 to n do
begin
f[i,2]:=f[i-1,2];
if a[i]=2 then f[i,2]:=f[i,2]+f[i-1,1];
end;
for i:=1 to n do
begin
f[i,3]:=f[i-1,3];
if a[i]=3 then f[i,3]:=f[i,3]+f[i-1,2];
end;
writeln(f[n,3]);
close(input);
close(output);
end.