#Lutece3203. 奇怪的筛

奇怪的筛

Migrated from Lutece 3203 奇怪的筛

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

有一个奇怪的筛子,这个筛子将所有正整数分为两类:过筛的和未过筛的。 1 到 9 均为过筛的数,对于大于 9 的数,其为过筛的需要满足以下条件:

  1. ⌊x/10⌋ 为过筛的数,其中 ⌊x⌋ 代表 x 向下取整。
  2. 在满足条件 1 的前提下,假设 ⌊x/10⌋ 为所有过筛的数中第 m 小的,x mod 10 要严格小于 m mod 11。

根据以上条件我们可以知道,1,2,3,4,5,6,7,8,9,10,20,21,30,31,32….为过筛的数。因为 3 为第三小的过筛的数,30、31、32都为过筛的数。 现在给定一个长度为 n 数字串 s ,请你求出所有 s 的子串组成的正整数中,有多少个是过筛的。如果两个子串相等但位置不同,认为是不同的子串。

Input

第一行一个正整数 n,代表字符串长度 第二行一个数字串,代表 s。

Output

一行一个正整数,代表满足条件的字串个数。

Samples

4
4021
6
3
110
3

Constraints

1<=n<=1051<=n<=10^5 保证 S 的第一个字符不是 0

Note

对于样例1,1,2,4,21,40,402 为满足条件的子串。

Resources

2024 UESTC ICPC Training for Search and Dynamic Programming