Here's what I did:
Starting from the lowest C on a grand piano, I went up to the last 88th key C in perfect fifths to see how many sharps there were in all sharped major keys, then from the lowest C I went up perfect fourths to see flat major keys there were. Then I did the same for the minor keys starting from the first A key on the piano going up fifths and then going up fourths (you can also go down fourths from the top key for the flat major or minor keys). Here's the chart I came up with while doing this:
So major keys: C G D A E B F# C# G# D# A# E# F Bb Eb Ab Db Gb Cb Fb Bbb Ebb Abb which adds up to 23 major keys.
For minor keys: A E B F# C# G# D# A# E# B# F## C## D G C F Bb Eb Ab Db Gb Cb Fb which also adds up to 23 minor keys.
23 + 23 = 46
Although a lot of the keys that have double sharps and flats and odd keys like E# Major and Fb minor are theoretical, very far from practical, I would never imagine anyone using C## minor instead of D minor unless you're going into C## minor from a key that has a bunch of sharps and double sharps, which are still unlikely to be used I'd imagine.
Is this correct? Are there theoretically 46 keys? Or did I miscalculate or misinterpret something?