You iterate over the pages until there are no results is no cursor, then you have reached the end. You cannot know the number of results until you've reached the end.
Just wanted to post to notify you that I updated my answer. You reach the end of standard analytics queries when the result set is empty. But with jobs, there won't be a cursor in the response when there are no more results that can be fetched.