{$U-}
module happy_tikets;

use system, iostd, math, putnum;

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


var
  N<0>,SUM[56];

sub init_sum
  cycle 1000 do
    inc(@SUM+2*sum(pred(_cx)))
  loop
ret

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

sub calculate_sum
  cycle 1000 do
    @N += word(@SUM+2*sum(pred(_cx)))
  loop
ret

sub write_sum;
  putword(N-1);
  putstring ' happy tikets';
  cr
ret


sub main
  init_sum;
  calculate_sum;
  write_sum
ret

end