[Python] Check four directions: NE, NW, SW, SE.
Code

# Code
```python3 []
class Solution:
    def maxDistance(self, s: str, k: int) -> int:
        d_cnt = collections.defaultdict(int)
        ans = 0
        for c in s:
            d_cnt[c] += 1

            p1_dist = d_cnt['N'] + d_cnt['E']
            p2_dist = d_cnt['N'] + d_cnt['W']
            p3_dist = d_cnt['S'] + d_cnt['W']
            p4_dist = d_cnt['S'] + d_cnt['E']

            org_max = max(p1_dist, p2_dist, p3_dist, p4_dist)
            if org_max == p1_dist:
                opps = d_cnt['S'] + d_cnt['W']
            elif org_max == p2_dist:
                opps = d_cnt['S'] + d_cnt['E']
            elif org_max == p3_dist:
                opps = d_cnt['N'] + d_cnt['E']
            else:
                opps = d_cnt['N'] + d_cnt['W']
            
            if opps <= k:
                ans = max(ans, org_max + opps)
            else:
                ans = max(ans, org_max + k - (opps - k))
        
        return ans
        
```
['Python3']