No, it isn't a stack problem, as there are no stack-operations (e.g. recurrence).
Before posting your code, check it locally with
- boundary cases, e.g. "1 1"
- worst case, i.e. "999900000 1000000000" (time limit! SPOJ machines are slow!)
- some random stuff (e.g. "9 13" for which your code produces the wrong result as I posted before)
If it has passed all these tests, then - maybe
- it will get AC.
P.S. Work on it, don't give up. For me, PRIME1 was the first problemset at SPOJ. I spent days on it and until now my solution is the fastest pure python solution (i.e. without psyco).