<p>There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.</p>

<p>Given a string <code>text</code> of words separated by a single space (no leading or trailing spaces) and a string <code>brokenLetters</code> of all <strong>distinct</strong> letter keys that are broken, return <em>the <strong>number of words</strong> in</em> <code>text</code> <em>you can fully type using this keyboard</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> text = &quot;hello world&quot;, brokenLetters = &quot;ad&quot;
<strong>Output:</strong> 1
<strong>Explanation:</strong> We cannot type &quot;world&quot; because the &#39;d&#39; key is broken.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> text = &quot;leet code&quot;, brokenLetters = &quot;lt&quot;
<strong>Output:</strong> 1
<strong>Explanation:</strong> We cannot type &quot;leet&quot; because the &#39;l&#39; and &#39;t&#39; keys are broken.
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> text = &quot;leet code&quot;, brokenLetters = &quot;e&quot;
<strong>Output:</strong> 0
<strong>Explanation:</strong> We cannot type either word because the &#39;e&#39; key is broken.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= text.length &lt;= 10<sup>4</sup></code></li>
	<li><code>0 &lt;= brokenLetters.length &lt;= 26</code></li>
	<li><code>text</code> consists of words separated by a single space without any leading or trailing spaces.</li>
	<li>Each word only consists of lowercase English letters.</li>
	<li><code>brokenLetters</code> consists of <strong>distinct</strong> lowercase English letters.</li>
</ul>

class Solution:
    def canBeTypedWords(self, text: str, s: str) -> int:
        out = 0

        words = text.split()
        ok = True
        
        for w in words:
            for c in w:
                if c in s:
                    ok = False
                    break
                ok = False
            else:
                w = True
                out += 1

        return out
        
        """
        s = set(brokenLetters)

        text += (' ')
        len_text = len(text)
        
        bad = False
        word = ""
        out = 0
        i = 0
        while i < len_text:
            if text[i] in s:
                #print("found bad:", text[i])
                while text[i] != ' ':
                    word += text[i]
                    i += 1
                bad = True
            
            if text[i] == ' ':
                if not bad:
                    #print("found good:", word)
                    out += 1

                #print("word:", word)
                bad = False
                word = ""
            else:
                word += text[i]

            i += 1

        return out
        """

        """
        len_broken = 0
        broken = set()

        for l in brokenLetters:
            broken.add(l)
        
        texts = text.split()
        found = set()
        f = False
        out = 0
        for text in texts:
            if text in found: out += 1; continue
            if text in broken: continue

            for t in text:
                if t in broken:
                    f = True
                    break
            
            if f == False:
                found.add(text)
                out += 1
            else:
                broken.add(text)
                f = False

        return out
        """
27