# Base Jumping

Consider a positive integer $N$ written in base $b$. A sequence is generated from this number by finding the largest digit $d$ in the expansion of $N$ and writing $N$ in base $d+1,$ repeating until the base the number is written in can be decreased no further. For example, the sequence generated by $346_{10}$ in base $16$ has length $6$: $15A_{16} = 295_{11} = 346_{10} = 1003_7 = 11122_4 = 110211_3$. Note that the next term in the sequence would be in base $3$ again, which is invalid since the base does not decrease.

There exists a single $N<10000$ and $b<100$ that generates a sequence with maximal length. Find $N+b.$

×