The first number after the patch (5000 in your example) is for determining the order which the patches are to be applied. Therefore unless a patch needs to be applied first before your one, you don't have to worry about it, just put any number.
As for the digit after -p, it depends on the prefix of the patch, since I don't know a better way to explain this I'll give you an example:
Suppose you have a source tar ball myprogram.tar.gz with the following content:
and you need to apply a patch to src/main.c in your spec file in order to build an RPM, first you'd open the patch with a text editor, on the first few lines you should see something like this:
--- src/main.c Fri Feb 13 00:00:00 2004
+++ src/main.c Sat Feb 14 00:00:00 2004
this tells you which file its going to patch, since the rpmbuild procedure applie patches relative to the root build directory (in this case "myprogram/"), and the path to the file is correct, we use -p0.
Suppose the patch has the following header instead:
--- myprogram/src/main.c Fri Feb 13 00:00:00 2004
+++ myprogram/src/main.c Sat Feb 14 00:00:00 2004
Then we need to use -p1, which will make it ignore the "myprogram/" part. If we have "whatever/myprogram/src/main.c" then we need to use -p2, so on and so forth.
It all comes down to the current working directory, with rpmbuild its the build directory (/usr/src/<distro>/BUILD/whatever)
To demonstrate this further I'll give you another quick example, if you're going to apply the patch in the first example manually, and your current working directory is something like "/home/user1/myprogram", then you use -p0 to apply the patch. But if its "home/user1/myprogram/src" then you can still apply the same patch with -p1.
Hope this helps