DP: Python 3 Easy To understand
\nclass Solution:\n    def countTexts(self, s: str) -> int:\n        mod = 1000000007\n        def rec2(n):\n            if n==1:\n                return 1\n   
```\nclass Solution:\n    def countTexts(self, s: str) -> int:\n        mod = 1000000007\n        def rec2(n):\n            if n==1:\n                return 1\n            if n==2:\n                return 2\n            if n==3:\n                return 4\n            if n==4:\n                return 8\n            dp = [0]*(n+1)\n            dp[1]=1\n            dp[2]=2\n            dp[3] = 4\n            dp[4] = 8\n            for i in range(5,n+1):\n                dp[i] = dp[i-1]+dp[i-2]+dp[i-3]+dp[i-4]\n\n            return dp[-1]\n            \n\n        def rec(n):\n            \n            if n==1:\n                return 1\n            if n==2:\n                return 2\n            if n==3:\n                return 4\n            dp = [0]*(n+1)\n            dp[1]=1\n            dp[2]=2\n            dp[3] = 4\n            for i in range(4,n+1):\n                dp[i] = dp[i-1]+dp[i-2]+dp[i-3]\n\n            return dp[-1]\n        ans = 1\n        cnt = 1\n        for i in range(1,len(s)):\n            if s[i]!=s[i-1]:\n                if s[i-1] not in[\'7\',\'9\']:\n                    ans*=(rec(cnt)%mod)\n                else:\n                    ans*=rec2(cnt)%mod\n                cnt = 1\n            else:\n                cnt+=1\n        ans = ans*rec(cnt) if s[-1] not in[\'7\',\'9\'] else ans*rec2(cnt)\n        return ans%mod\n\t```
['Dynamic Programming', 'Python']