initial value of semaphore $S$ is $1$
$P_2$ needs to access , decrement $S$ by $1$ $ ( S = S - 1 = 1-1 = 0)$
$P_1$ needs to access , decrement $S$ by $1$ $( S = S - 1 = 0 - 1 = -1)$
$P_3$ needs to access , decrement $S$ by $1$ $( S = S - 1 = -1 - 1 = -2)$
$P_2$ exits the critical section , increment $S$ by $1$ $( S = S + 1 = -2 + 1 = -1)$
$P_1$ exits the critical section , increment $S$ by $1$ $( S = S + 1 = -1 + 1 = 0)$
The final value is $0$