How to find index of n-th value equal to a specific value

Suppose
a=torch.randint(3, (10,))
gives

tensor([2, 2, 0, 2, 2, 2, 2, 0, 1, 2])

Now I want to find the index of 3rd value equal to 2, which is 3 in this example. Because

a[0]=2, a[1]=2, a[3]=2

How can I do this?

I think that one should work
(a==2).nonzero()[2]