It depends on the difference between the speed of light and the speed of sound. The thunder lags five (I was taught seven but Mike was right) seconds per mile behind the thunder.
Of course the speed of sound is highly variable so it’s only a rule of thumb.
https://www.livescience.com/37734-how-far-away-is-lightning-distance.html