Let the total number of packets sent be $x.$
First, four packets $(\text{Numbered}\; 1\;\text{to}\; 4)$ sent. No loss, ack comes back. $x = 4.$
Next four packets are sent. Packet number $6$ is lost. Packets $7$ and $8$ are successful transmission but being out of order they will be rejected. Packet $9$ is sent when ack of packet $5$is received and this will be rejected as well. $x =4+5= 9.$
Packets from $6$ to $9$ are sent. Packet $8$ is lost as it is the $6^{\text{th}}$ packet since the previous lost packet. When ack for packet $7$ is received, packets $10$ and $11$ will be sent and these will be rejected being out of order. $x = 9+4+2=15.$
Packets $8$ to $11$ are sent. Packet number $10$ will be lost. When ack for packet $9$ comes, packet $12$ will be sent and this will be rejected being out of order. So, $x = 15+4+1 = 20.$
Packets $10$ to $12$ are sent. No loss. So, $x = 20+3 = 23.$
So, total number of packets sent $ = 23.$