Start with 1 whole jar
remove 1/2 then 1/2 is left
removing 2/5 of the 1/2 leaves 3/5 of the 1/2
3/5 * 1/2 = 3/10 now are left
removing 2/3 leaves 1/3 of what is left
1/3 * 3/10 = 3/30 of the original and this is equal to 4
3/30 x = 4 x = 4 * 30 /3 = 40 cookies originally