Const
  file1 = 'input.txt';
  file2 = 'strings.txt';
  file3 = 'numbers.lnt';
  nums  = ['0'..'9'];
Var
  ch        : char;
  numstr    : string;
  i         : integer;
  f1        : text;
  f2        : text;
  f3        : file of longint;
  num       : longint;
  code      : integer;
  mode      : boolean;
Begin
  Assign(f1,file1);
  Reset(f1);
  Assign(f2,file2);
  Rewrite(f2);
  Assign(f3,file3);
  Rewrite(f3);
  mode := false;
  repeat
    read(f1,ch);
    if mode then
      begin
      if ch in nums then numstr := numstr+ch
      else
        begin
          mode := false;
          Write(f2,ch);
          if length(numstr) < 10 then
            begin
              val(numstr,num,code);
              Write(f3,num);
            end
          else Write(f2,numstr);
        end;
      end
    else
      begin
      if ch in nums then
        begin
          mode := true;
          numstr := ch;
        end
      else Write(f2,ch);
      end;
  until EOF(f1);
  Close(f1);
  Close(f2);
  Close(f3);
End.