var
  m : array[1..8] of int64;
  a, b : int64;
  c, i, ans : integer;
  fl : boolean;

function pow(a, b : int64) : int64;
begin
  if (a = 0) then begin
    result := 0;
    exit;
  end;
  result := 1;
  while (b <> 0) do begin
    if (b mod 2 = 1) then begin
      if (a > 1e18 / result) then begin
        fl := true;
        exit;
      end;
      result := result * a;
    end;
    b := b div 2;
    a := a * a;
    if (a > 1e18 / a) then begin
      fl := true;
      exit;
    end;
  end;
end;

procedure qsort(l, r : integer);
var
  i, j : integer;
  x, t : int64;
begin 
  if (r <= l) then exit;
  i := l;
  j := r;
  x := m[random(r - l + 1) + l];
  while (i <= j) do begin
    while (m[i] < x) do i := i + 1;
    while (m[j] > x) do j := j - 1;
    if i <= j then begin
      t := m[i]; m[i] := m[j]; m[j] := t;
      i := i + 1; j := j - 1;
    end;
  end;
  qsort(l, j);
  qsort(i, r);
end;

begin
  reset(input, 'differ.in');
  rewrite(output, 'differ.out');
  read(a, b);
  m[1] := a + b;
  m[2] := a - b;
  m[3] := a * b;
  m[4] := b - a;
  c := 4;
  ans := 0;
  if (b >= 0) then begin
    c := c + 1;
    fl := false;
    m[c] := pow(a, b);
    if (fl) then begin
      c := c - 1;
      writeln(erroutput, a, '^', b);
      ans := ans + 1;
    end;
  end else begin
    if (a = 1) then begin
      c := c + 1;
      m[c] := 1;
    end else begin
      if (a = -1) then begin
        if (b mod 2 = 0) then begin
          c := c + 1;
          m[c] := 1;
        end else begin
          c := c + 1;
          m[c] := -1;
        end;
      end else begin
        if (a <> 0) then begin
          writeln(erroutput, a, '^', b);
          ans := ans + 1;
        end;
      end;
    end;
  end;
  if (a >= 0) then begin
    c := c + 1;
    fl := false;
    m[c] := pow(b, a);
    if (fl) then begin
      c := c - 1;
      if (a <> b) then begin
        writeln(erroutput, b, '^', a);
        ans := ans + 1;
      end;
    end;
  end else begin
    if (a = -1) and (b = 1) then begin
      c := c + 1;
      m[c] := 1;
    end else begin
      if (b = -1) then begin
        if (a mod 2 = 0) then begin
          c := c + 1;
          m[c] := 1;
        end else begin
          c := c + 1;
          m[c] := -1;
        end;
      end else begin
        if (b <> 0) and (a <> b) then begin
          writeln(erroutput, b, '^', a);
          ans := ans + 1;
        end;
      end;
    end;
  end;
  if (b <> 0) and (a mod b = 0) then begin
    c := c + 1;
    m[c] := a div b;
  end else begin
    if (b <> 0) then begin
      writeln(erroutput, a / b);
      ans := ans + 1;
    end;
  end;
  if (a <> 0) and (b mod a = 0) then begin
    c := c + 1;
    m[c] := b div a;
  end else begin
    if (a <> 0) and (a * a <> b * b) then begin
      writeln(erroutput, b / a);
      ans := ans + 1;
    end;
  end;
  qsort(1, c);
  ans := ans + 1;
  writeln(erroutput, m[1]);
  for i := 1 to c - 1 do begin
    if (m[i] <> m[i + 1]) then begin
      writeln(erroutput, m[i + 1]);
      ans := ans + 1;
    end;
  end;
  writeln(ans);
end.