{$U-}
module happy_tikets;

use system, iostd, math, putnum;

var
  A,B,C,D,E,F,N<0>;

sub check_happy
  if A+B+C == D+E+F then
    TRUE
  else
    FALSE
  fi
ret

sub putsn
  putword(A);
  putword(B);
  putword(C);
  putword(D);
  putword(E);
  putword(F);
  cr;
ret

sub pred_cx var c*;
  c = _cx - 1;
ret


sub main
  cycle 10 do
    pred_cx(@A);
    cycle 10 do
      pred_cx(@B);
      cycle 10 do
        pred_cx(@C);
        cycle 10 do
          pred_cx(@D);
          cycle 10 do
            pred_cx(@E);
            cycle 10 do
              pred_cx(@F);
              if check_happy then inc(@N);{putsn;}fi;
            loop
          loop
        loop
      loop
    loop
  loop
  putword(N-1);
  putstring ' happy tikets'; cr;
ret

end

