N is count_successes(Goal)
Here Goal has to be an atomic goal. After the execution of this function the returned value N will contain the number of the times Goal succeeded. If Goal succeeds infinitely many times then this function will go in an infinite loop.
read(X,"Say how many times"),