We will observe the given bit pattern of 7 bit binary string and then try to make it accept.
Given that D1, D4 and D7 are 1.
We will try different combinations of D2 and D3 and on requirement to get the string accepted by machine we'll adjust the D5 D6 bits.
D1 
D2 
D3 
D4 
D5 
D6 
D7 
Remarks 
1 
0 
0

1 
X 
X 
1 
Case 1 
1 
0 
1 
1 
0 
0 
1 
Case 2 
1 
1 
0 
1 
0 
0 
1 
Case 3 
1 
1 
1 
1 
0 
0 
1 
Case 4 
Case 1 : When D2 and D3 are 0 0 : the string starts with 1001 and after that whatever comes will be accepted because 1001 will move to final state. D5 and D6 are marked as Don't Cares as whether they are 0 or 1 it doesn't matter string will get accepted.
So number of combinations for this string?
D5 can take 2 values (0 or 1)
D6 can take 2 values (0 or 1)
total strings for this case which will be accepted : 4
Case 2 : When D2 and D3 are 0 1 : Now D5 and D6 both need to be 0 0 for the string to be accepted.
Number of String for this case  1
Case 3: When D2 and D3 are 1 0 : Similar to case 2, D5 and D6 both need to be 0 0 for the string to get accepted.
Number of String for this Case : 1
Case 4 : When D2 and D3 are 1 1 : Here also D5 and D6 need to be 0 0 for the string to be accepted.
Number of String for this Case : 1
Now we have finally exhausted all cases where a 7 bit string can be accepted by this machine M.
Total number of strings :
4+1+1+1=7 Ans(Add up all cases)