def count(text, pattern):
    """How many times the given pattern appears in the text"""
    i = 0
    n = 0
    while i <= len(text) - len(pattern):
        if text[i:i+len(pattern)] == pattern:
            n = n + 1
        i = i + 1
    return n