Please solve the programming task below using a self-contained code snippet in a markdown code block.

Given a string s, return the length of the longest substring that contains at most two distinct characters.
 
Please complete the following python code precisely:
```python
class Solution:
    def lengthOfLongestSubstringTwoDistinct(self, s: str) -> int:
```