I assume you know that $ 4 $ Conditions that are required for the system to be in a deadlock.

Let's see if there are any $ n $ Processes in the system $ P_1, P_2, P_3, ……, P_n $ Where

process $ P_1 $ requires $ x_1 $ commodity units $ R $

process $ P_2 $ requires $ x_2 $ resource units $ R $

process $ P_3 $ requires $ x_3 $ resource units $ R $

…..

process $ P_n $ requires $ x_n $ resource units $ R $

In the worst case, for a deadlock to exist, the number of units each process contains is one less than the maximum requirement. So we can say that the system is deadlocked.

process $ P_1 $ keeps $ x_1 -1 $ resource units $ R $

process $ P_2 $ keeps $ x_2 -1 $ resource units $ R $

process $ P_3 $ keeps $ x_3 -1 $ resource units $ R $

…..

process $ P_n $ keeps $ x_n -1 $ resource units $ R $

To overcome the impasse, we only need one resource unit $ R $ In the system.

This is because this unit is assigned to one of the processes, executed, and then releases the resources it contains that can be used by other processes.

From here we can say

Maximum number of resource units $ R $ that secures deadlock

$ = (x_1-1) + (x_2-1) + (x_3-1) + …. + (x_n-1) $

$ = (x_1 + x_2 + x_3 + …. + x_n) – n $

$ = sum_ {x = 1} ^ nx_i – n $

Now in your question, $ n = 6 $ and $ x_i = 2 $, The values of $ x_i $ and $ n $

$ = 2 + 2 + 2 + 2 + 2 + 2 – 6 $

$ = 6 $

So the maximum units of $ R $ required to cause deadlock $ 6 $