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 such that the frequency of each character in this substring is greater than or equal to k.
if no such substring exists, return 0.
 
Please complete the following python code precisely:
```python
class Solution:
    def longestSubstring(self, s: str, k: int) -> int:
```