Routine is the 40th. The count goes up to 40 when it's purchased, but then it gets reset immediately so it goes right back to 0 or 39 before the UI updates the count.
Oh, that makes sense.
I could swear Routine was #39, but guess not.
(In terms of how many total you've seen, it really should keep track of that though.)
I may just remove the count. It seems like the best option.
That, or I will exclude wacky upgrades like Routine from the count.