func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int Max(int x, int y, int z) { return max(max(x, y), z); }   const int N = 100005;   int n, m;   char s[N];   long long f[N][10];   int st[3], to[3];   long long ans;   inline int R(int b, int a[3]) {     if (a[1] != b && a[1] != b - 1) return 8;     int x = (a[1] < b ? 0 : 1);     int y = a[1] - a[0];     if (y != 0 && y != 1) return 8;     int z = a[2] - a[1];     if (z != 0 && z != 1) return 8;     return x + (y << 1) + (z << 2);   }   inline void T(int b, int S, int a[3]) {     int x = S & 1;     int y = S >> 1 & 1;     int z = S >> 2 & 1;     a[1] = (!x ? b - 1 : b);     a[0] = a[1] - y;     a[2] = a[1] + z;   }   inline void G(int b, char c) {     to[0] = max(st[1], st[0] + (c == s[b]));     to[1] = Max(to[0], st[2], st[1] + (c == s[b + 1]));     to[2] = max(to[1], st[2] + (c == s[b + 2]));   }   int main(void) {     scanf( %d %d , &n, &m);     scanf( %s , s + 1);     if (n <= 1) return printf( %d n , m - 1), 0;     if (s[1] == s[2]) {       st[0] = 0, st[1] = 0, st[2] = 0, f[1][R(1, st)] = m - 1;       st[0] = 0, st[1] = 1, st[2] = 1, f[1][R(1, st)] = 1;     } else {       st[0] = 0, st[1] = 0, st[2] = 0, f[1][R(1, st)] = m - 2;       st[0] = 0, st[1] = 1, st[2] = 1, f[1][R(1, st)] = 1;       st[0] = 0, st[1] = 0, st[2] = 1, f[1][R(1, st)] = 1;     }     for (register int i = (1), _b = (n - 1); i <= _b; i++)       for (register int S = (0), _b = (7); S <= _b; S++)         if (f[i][S] != 0) {           T(i, S, st);           for (register int j = (1), _b = (m); j <= _b; j++) {             G(i,  a  + j - 1);             f[i + 1][R(i + 1, to)] += f[i][S];           }         }     for (register int S = (0), _b = (7); S <= _b; S++)       if (f[n][S] != 0) {         T(n, S, st);         if (st[1] == n - 1) ans += f[n][S];       }     printf( %I64d n , ans);     return 0;   }   