Imagine that you're solving this problem on an array rather than an AVL tree. How might you go about doing this? First, start by doing a binary search over the array to find the smallest number s greater than p. If that number is greater than p+1, just return p+1. Otherwise, we're in the middle of some run of elements and need to find the smallest number that's past the run. To do so, you can think about solving the following problem: find the smallest element x such that x - s is greater than the index of x minus the index of s. This can be done by doing a binary search on the remaining half of the array: if the difference between the current element and s is equal to the distance between the current element and s, go right, otherwise go left. Once you've found this element x, go to the element before it, add one, and that's your answer.
To solve this problem on the AVL tree, you essentially adapt the above algorithm to use tree searches rather than binary searches. The fact that you have subtree size information means that you can determine the index of any element in the tree using the standard order statistics technique. I imagine the final algorithm will be a bit messy, but it will faithfully simulate the above algorithm in time O(log n).