Inclusion–exclusion principle ^^
\n\n\n\n\n\nint stringCount(int n)\n{\n\tlong long a{1}, b{1}, c{1}, d{1}, p{1000000007};\n\tfor(int i{}; i+1<n; ++i)\n\t{\n\t\ta = (26*a)%p;\n\t\tb = (25*b)%p;
![image](https://assets.leetcode.com/users/images/004766be-a93d-430b-9681-a7a64d09ac33_1703250102.583628.png)\n\n![image](https://assets.leetcode.com/users/images/91a0ed1b-82d5-4cb0-a07d-ce7b0e07620f_1703253490.5620298.png)\n\n\n```\nint stringCount(int n)\n{\n\tlong long a{1}, b{1}, c{1}, d{1}, p{1000000007};\n\tfor(int i{}; i+1<n; ++i)\n\t{\n\t\ta = (26*a)%p;\n\t\tb = (25*b)%p;\n\t\tc = (24*c)%p;\n\t\td = (23*d)%p;\n\t}\n\tlong long out = (p-n*(b-2*c+d))%p;\n\ta = (26*a)%p;\n\tb = (25*b)%p;\n\tc = (24*c)%p;\n\td = (23*d)%p;\n\tout = (out + 4*p + a - 3*(b-c) - d)%p;\n\treturn out;\n}\n```
['C', 'C++']