Use the EEPROM idea but write to the EEPROM once during run time.

But before you write Z, maybe add 37 or something to it.