5

You are a bona fide foreign resident. (The fact that you are not a permanent resident is irrelevant.) Therefore the physical presence test does not apply to you.
The fact that you were a student (or otherwise without earned income) is irrelevant.
The fact that you moved from one foreign count...