```python
import collections

def rearange_string(S):
    """
    Checks if the letters of a given string can be rearranged so that
    two characters that are adjacent to each other are different.
    """
    if not S:
        return True

    n = len(S)
    counts = collections.Counter(S)
    max_freq = max(counts.values())

    # The count of the most frequent character must not be more than
    # the count of all other characters plus one.
    # Let max_freq be the frequency of the most frequent character.
    # The number of other characters is (n - max_freq).
    # The condition is: max_freq <= (n - max_freq) + 1
    # which simplifies to: 2 * max_freq <= n + 1
    return 2 * max_freq <= n + 1
```