{$J+,3+,U-}
module happy_tikets;
{$S 200}
use system, iostd, math, putnum;

{$V+}sub sum var val*;
  if val>0 then
    sum(val/10)+val%10
  else
    0
  fi
ret

var
  N<0>,SUM[56];

inline x2 (0x03,0xC0);

inline += [10] (
  0x5B,		{pop bx}
  0x01,0x07,	{add [bx], ax}
  0x58)		{pop ax}

{$V-}sub main var i;
  cycle 1000 do
    @i=x2(sum(pred(_cx)));
    inc(@SUM+i);
    @N+=pred(x2(word(@SUM+i)))
  loop
  putword(pred(N));putstring ' happy tikets'; cr;
ret
end

