When you enter the baggage reclaim area, you can already by a train ticket. This is a good time to do it, since you will most likely have to wait for your baggage anyway. If you arrived in Terminal A, you will be coming from below the red A. If you arrived in Terminal B, you will be coming from below the red B. You can buy tickets at anyone of the teal cuboids near the bottom of the letters. If there is a queue at one of them, it might be good to check whether the other one is free.