#P1710C. XOR Triangle

    ID: 917 Type: RemoteJudge 4000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 9 Uploaded By: Tags>bitmasksbrute forceconstructive algorithmsdpgreedymath*2500

XOR Triangle

Description

You are given a positive integer nn. Since nn may be very large, you are given its binary representation.

You should compute the number of triples (a,b,c)(a,b,c) with 0a,b,cn0 \leq a,b,c \leq n such that aba \oplus b, bcb \oplus c, and aca \oplus c are the sides of a non-degenerate triangle.

Here, \oplus denotes the bitwise XOR operation.

You should output the answer modulo 998244353998\,244\,353.

Three positive values xx, yy, and zz are the sides of a non-degenerate triangle if and only if x+y>zx+y>z, x+z>yx+z>y, and y+z>xy+z>x.

The first and only line contains the binary representation of an integer nn (0<n<22000000 < n < 2^{200\,000}) without leading zeros.

For example, the string 10 is the binary representation of the number 22, while the string 1010 represents the number 1010.

Print one integer — the number of triples (a,b,c)(a,b,c) satisfying the conditions described in the statement modulo 998244353998\,244\,353.

Input

The first and only line contains the binary representation of an integer nn (0<n<22000000 < n < 2^{200\,000}) without leading zeros.

For example, the string 10 is the binary representation of the number 22, while the string 1010 represents the number 1010.

Output

Print one integer — the number of triples (a,b,c)(a,b,c) satisfying the conditions described in the statement modulo 998244353998\,244\,353.

Sample Input 1

101

Sample Output 1

12

Sample Input 2

1110

Sample Output 2

780

Sample Input 3

11011111101010010

Sample Output 3

141427753

Note

In the first test case, 1012=5101_2=5.

  • The triple (a,b,c)=(0,3,5)(a, b, c) = (0, 3, 5) is valid because (ab,bc,ca)=(3,6,5)(a\oplus b, b\oplus c, c\oplus a) = (3, 6, 5) are the sides of a non-degenerate triangle.
  • The triple (a,b,c)=(1,2,4)(a, b, c) = (1, 2, 4) is valid because (ab,bc,ca)=(3,6,5)(a\oplus b, b\oplus c, c\oplus a) = (3, 6, 5) are the sides of a non-degenerate triangle.

The 66 permutations of each of these two triples are all the valid triples, thus the answer is 1212.

In the third test case, 110111111010100102=11451411\,011\,111\,101\,010\,010_2=114\,514. The full answer (before taking the modulo) is 14664081188081641\,466\,408\,118\,808\,164.