Clean + concise code🎉 {well explained} 
IntuitionApproachThe code is self explanatory. We need to cancel out the opposing directions.
The ans should be updated at every step!!Complexity
Time complexit
# Intuition 
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach 
The code is self explanatory. We need to cancel out the opposing directions.
**The ans should be updated at every step!!**
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int maxDistance(string sh, int k) {
        int ans = 0;
        int n = 0, w = 0, s = 0, e = 0;

        for (char ch : sh) {
            if (ch == 'N') {
                n++;
            } else if (ch == 'S') {
                s++;
            } else if (ch == 'E') {
                e++;
            } else {
                w++;
            }

            int max_vertical_dist = max(n, s);
            int cancelled_vertical_dist = min(n, s);

            int max_horizontal_dist = max(e, w);
            int cancelled_horizontal_dist = min(e, w);

            // we need to change the directions that are cancelling
            int need_to_change =
                min(cancelled_vertical_dist + cancelled_horizontal_dist, k);

            ans = max(ans, max_vertical_dist + max_horizontal_dist -
                               cancelled_vertical_dist -
                               cancelled_horizontal_dist + 2 * need_to_change); 
//2*need_to_change => consider a string SN : net distance is 0 
//but if S is converted to N => net distance will be 2 => the S 
//itself and the N alrdy present
        }

        return ans;
    }
};
```
['Greedy', 'C++']