An integer \(N\) (1 ≤ \(N\) ≤ 1000), representing some quantity or size.
An integer \(M\) (0 ≤ \(M\) ≤ \(N\)), representing some quantity.
An integer \(A\) (1 ≤ \(A\) ≤ 1000), representing some threshold.
An integer \(B\) (1 ≤ \(A\) ≤ \(B\) ≤ 1000), representing another threshold.
A list of integers \(D\) of size \(N\) where each integer is between 1 and 1000.

### Example Input:

```
5 3 6 9
9 7 5 3 1
```

### Function Signature:

Write a function `f(N, M, A, B, D)` that takes in the input.
def f(N: int, M: int, A: int, B: int, D: List[int]):
    '''
    N: an integer
    M: an integer
    A: an integer
    B: an integer
    D: a list of integers
    '''