var
m,b:real;
n,p,i,j,k,l,ii:longint;
a:array[1..100] of char;
{procedure zhuan(m:real;,p:longint;) }
begin
i:=0;
while not eoln do
begin
inc(i);
read(a[i]);
end;
readln(n);
k:=i;
l:=k;
for i:=1 to k do
if a[i]='.' then begin l:=i; end;
if l<>k then begin
for j:=1 to l do
if ord(a[j])>=65 then
b:=b+exp(ln(n)*(l+j-1))*(ord(a[j])-55)
else b:=b+(ord(a[j])-48)*exp(ln(n)*(l+j-1));
for ii:=1 to k-l do
if ord(a[j])>=65 then
b:=b+exp(ln(n)*(-ii))*(ord(a[l+ii])-55)
else
b:=b+(ord(a[l+ii])-48)*exp(ln(n)*(-ii));
end;
if l=k then begin
for j:=1 to k do
if ord(a[j])>=65 then
b:=b+exp(ln(n)*(j))*(ord(a[j])-55)
else
b:=exp(ln(n)*j)*(ord(a[j])-48) ;
end;
end.
m,b:real;
n,p,i,j,k,l,ii:longint;
a:array[1..100] of char;
{procedure zhuan(m:real;,p:longint;) }
begin
i:=0;
while not eoln do
begin
inc(i);
read(a[i]);
end;
readln(n);
k:=i;
l:=k;
for i:=1 to k do
if a[i]='.' then begin l:=i; end;
if l<>k then begin
for j:=1 to l do
if ord(a[j])>=65 then
b:=b+exp(ln(n)*(l+j-1))*(ord(a[j])-55)
else b:=b+(ord(a[j])-48)*exp(ln(n)*(l+j-1));
for ii:=1 to k-l do
if ord(a[j])>=65 then
b:=b+exp(ln(n)*(-ii))*(ord(a[l+ii])-55)
else
b:=b+(ord(a[l+ii])-48)*exp(ln(n)*(-ii));
end;
if l=k then begin
for j:=1 to k do
if ord(a[j])>=65 then
b:=b+exp(ln(n)*(j))*(ord(a[j])-55)
else
b:=exp(ln(n)*j)*(ord(a[j])-48) ;
end;
end.