Observe closely, In both P1 and P2 writing to B is happening only at second(final) statement.
Case I: P2 value get's overwritten by P1 $\Rightarrow$ Only P1
It's like in effect only P1 executes. With B=2 as initial value, final value will be 2.
Case II: P1 value gets overwritten by P2 $\Rightarrow$ Only P2
With B=2 as initial value final value will be 3.
Case III: P2 executes first and writes the value which is read by P1 $\Rightarrow$ P2 then P1
P2 writes 3 as in Case II. With B=3 P1 writes final value 4.
Case IV: P1 executes first and writes the value which is read by P2 $\Rightarrow$ P1 then P2
P1 writes value 2 as in Case I which is same as initial value. So as in Case II P2 writes final value 3 with initial value 2.
So in effect there are only 3 possible values which are {2,3,4}. Answer: 3