To be on the safe side, make a note of the current exposure number. If your camera somehow messes this up, none of my cameras ever have, rewind the film and then shoot blank photos until you get back to your previous shot number, shoot one more for safety, and resume.
I have changed batteries on multiple cameras. In general the counter is only reset when you open and close the back.
Most electronic cameras have a little bit of nonvolatile memory which keeps track of frame number and basic settings.