Well, I'm not sure the answer is as simple as "no." If I understand this, those years do not count toward the "20" but if you put in 20 active duty/post Academy, then there is a retirement benefit for those additional 4 years.
Correct me if I'm not.
If you did time as prior enlisted or at a prep school (which essentially counts as prior enlisted) before entering an academy, that times counts towards your 20 however.
I don't believe part of your statement is correct, i.e. where you note "... or at a prep school." Foundation-designated prep school students receive no credit for that time. Only NAPSters.