An integer N (1 ≤ N ≤ 100), representing the length of the sequence.
A string S of length N, where each character is 'L', 'R', 'U', or 'D'.

### Example Input:

```
8
RUDLUDR
```

### Function Signature:
Write a function f(N, S) that takes in the input.
```python
def f(N: int, S: str):
    '''
    N: an integer
    S: a string
    '''
```