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

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