How do I deal with capital gain from 1099-B as a nonresident alien?

Hi,

 

I am a nonresident alien in 2022. The only income I got in 2021 are 1099-div, 1099-int and 1099-B.  I wonder should I pay any tax on the capital gain from stock market on 1099-B. If I do, is there any difference between long term and short term investment?

 

Thank you so much.