#include #include #include using namespace std; typedef long long ll; const int maxn = 200005; const ll MOD = 1e9 + 7; int n; string s; ll dp[maxn][8]; ll rec(int at, int remainder) { if(at == n and remainder == 0) { return 1; } if(at == n) { return 0; } if(dp[at][remainder] != -1) { return dp[at][remainder]; } ll res = 0; res += rec(at + 1, remainder); res %= MOD; int new_remainder = (remainder * 10 + (s[at] - '0')) % 8; res += rec(at + 1, new_remainder); res %= MOD; dp[at][remainder] = res; return res; } int main() { ios_base::sync_with_stdio(false); cin >> n >> s; memset(dp, -1, sizeof dp); cout << rec(0, 0) - 1 << endl; return 0; }