var
  k,f,d,i,h,t,carry : integer;
  s           : string;
  a,b,n,m,c   : array[1..1000] of integer;

function max(a,b:integer):integer;
begin
  if (a>b) then
    max := a
  else
    max := b;
end;

begin
  assign(input,'d.in');  reset(input);
  assign(output,'d.out');  rewrite(output);

  read(s);
  k := 0;
  d := 0;
  f := 0;
  h := 0;
  for i:=length(s) downto 1 do
    if (s[i]<>' ') then
      begin
        if (h=0) then
          begin
            k := k+1;
            b[k] := ord(s[i])-48;
          end;
        if (h=1) then
          begin
            d := d+1;
            a[d] := ord(s[i])-48;
          end;
        if (h=2) then
          begin
            f := f+1;
            n[f] := ord(s[i])-48;
          end;
      end
    else
      h := h+1;

  for i:=1 to f do
    if (n[i]<a[i]) then
      begin
        c[i] := n[i]+10-a[i];
        if (n[i+1]-1<0) then
          begin
            t := i+1;
            while (n[t]-1<0) do
              begin
                n[t] := 10+n[t]-1;
                t := t+1;
              end;
            n[t] := n[t]-1;
          end
        else
          n[i+1] := n[1+i]-1;
      end
    else
      c[i] := n[i] - a[i];

  while (c[f]=0) do
    f := f-1;

  carry := 0;
  d := max(f,k);
  for i:=1 to d do
    begin
      m[i] := b[i]+c[i]+carry;
      carry := m[i] div 10;
      m[i] := m[i] mod 10;
    end;

  if (carry>0) then
    begin
      d := d + 1 ;
      m[d] := carry;
    end;

  for i:=d downto  1 do
    write(m[i]);

  close(input); close(output);
end.
