{$q+,r+}
program checke;

uses
    testlib, sysutils;

const
    allowed = ['0'..'9', 'a'..'z', 'A'..'Z', '.', ' '];
    max_l = 1000;
    eps = 0.005001;

var
    ch: char;
    c: array [char] of longint;
    pe, je: extended;
    n: longint;
begin
    n := 0;
    fillchar(c, sizeof(c), 0);
    while not ouf.eof() do begin
        ch := ouf.nextChar();
        if not (ch in allowed) then begin
            if ch in [#10, #13] then break;
            if ch < ' ' then begin
                quit(_PE, format('Invalid character: #%d', [ord(ch)]));
            end else begin
                quit(_PE, format('Invalid character: "%s"', [ch]));
            end;
        end;
        inc(c[ch]);
        inc(n);
        if n > max_l then begin
            quit(_WA, 'Output too long');
        end;
    end;
    pe := 0;
    for ch := low(c) to high(c) do begin
        if c[ch] <> 0 then begin
            pe := pe - (c[ch] / n) * ln(c[ch] / n);
        end;
    end;
    pe := pe / ln(2);
    je := inf.readReal();
    if abs(pe - je) > eps then begin
        quit(_WA, format('E=%0.4f instead of %0.2f', [pe, je]));
    end;
    quit(_OK, format('dE=%0.4f', [abs(je - pe)]));
end.