# include <stdio.h>
#include "lotos.hh"

extern kdatum one ();
extern kdatum succ ();

int
pnumber (n)
	kdatum n;
	{
	kdatum sn;
	int i;

	sn= one();
	i= 1;
	while (!kd_equal(sn, n)) {
	  i++;
	  sn= succ(sn);
	  }
	kd_free(sn);
	return i;
	}

main	(argc, argv)
	int	argc;
	char*	argv[];
	{
	void*	actual[1];
	kdatum	aux;
	int i;

	if (argc != 2) {
	  fprintf (stderr, "usage: %s <delay>\n", argv[0]);
	  exit (1);
	  }
	ldcinit ();
	i= atoi (argv[1]);
	aux= one ();
	while (i-- > 1)
	  aux= succ (aux);
	actual[0]= (void*)aux;
	lbcinit (1, actual);
	exit (sch ());
	}
