Problem:
Score : 1400 points

Problem Statement

Consider the following set of rules for encoding strings consisting of 0 and 1:

Strings 0 and 1 can be encoded as 0 and 1, respectively.

If strings A and B can be encoded as P and Q, respectively, then string AB can be encoded as PQ.

If string A can be encoded as P and K \geq 2 is a positive integer, then string AA...A (A repeated K times) can be encoded as (PxK).

For example, string 001001001, among other possibilities, can be encoded as 001001001, 00(1(0x2)x2)1 and (001x3).

Let's call string A a subset of string B if:

A and B are equal in length and consist of 0 and 1;

for all indices i such that A_i = 1, it's also true that B_i = 1.

You are given string S consisting of 0 and 1. Find the total number of distinct encodings of all subsets of S, modulo 998244353.

Constraints

1 \leq |S| \leq 100

S consists of 0 and 1.

Input

Input is given from Standard Input in the following format:

S

Output

Print the total number of distinct encodings of all subsets of S modulo 998244353.

Sample Input 1

011

Sample Output 1

9

There are four subsets of S:

011 can be encoded as 011 and 0(1x2);

010 can be encoded as 010;

001 can be encoded as 001 and (0x2)1;

000 can be encoded as 000, 0(0x2), (0x2)0 and (0x3).

Thus, the total number of encodings of all subsets of S is 2 + 1 + 2 + 4 = 9.

Sample Input 2

0000

Sample Output 2

10

This time S has only one subset, but it can be encoded in 10 different ways.

Sample Input 3

101110

Sample Output 3

156

Sample Input 4

001110111010110001100000100111

Sample Output 4

363383189

Don't forget to take the result modulo 998244353.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

// duck is bad
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <bitset>
using namespace std;

const int mod = 998244353;

typedef unsigned long long lu;
typedef bitset<100> Bitset;

bool operator < (const Bitset &a, const Bitset &b) {
  lu *p = (lu*)(&a), *q = (lu*)(&b);
  return p[1] == q[1] ? p[0] < q[0] : p[1] < q[1];
}

bool operator <= (const Bitset &a, const Bitset &b) {
  lu *p = (lu*)(&a), *q = (lu*)(&b);
  return p[1] == q[1] ? p[0] <= q[0] : p[1] < q[1];
}

struct Cmp {
  bool operator () (const Bitset &a, const Bitset &b) const {
    return a < b;
  }
};

int n;
char str[101];
map<Bitset, int, Cmp> dp;

// void Print(Long s) {
//   printf("%d ", (int)s);
//   while (s > 1) {
//     putchar('0' + (s & 1));
//     s >>= 1;
//   }
//   putchar('@');
// }

inline int Add(int a) {
  return a >= mod ? a - mod : a;
}

inline int Mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int Dfs(Bitset s) {
  if (dp.count(s)) {
    return dp[s];
  }
  dp[s] = Dfs(s >> 1);
  if (s[0]) {  // if (s & 1) {
    dp[s] = Add(dp[s] << 1);
  }

  int len = 0;
  Bitset single_bit;
  single_bit[1] = 1;
  while (single_bit <= s) {
    ++len;
    single_bit <<= 1;
  }

  Bitset one_d;
  for (int d = 1; d < len; ++d) {
    // Long t = s & ((Long)1 << d) - 1;
    one_d[d - 1] = 1;
    Bitset t = s & one_d;

    for (int k = 2; k * d <= len; ++k) {
      // t &= s >> (k - 1) * d & ((Long)1 << d) - 1;
      t &= s >> (k - 1) * d & one_d;
      // dp[s] = Add(dp[s] + Mul(Dfs(t | (Long)1 << d), Dfs(s >> k * d)));
      Bitset t2 = t;
      t2[d] = 1;
      dp[s] = Add(dp[s] + Mul(Dfs(t2), Dfs(s >> k * d)));
    }
  }

  // Print(s);
  // printf(" %d\n", dp[s]);
  return dp[s];
}

int main(void) {
  scanf("%s", str);
  n = (int)strlen(str);
  Bitset s;
  s[0] = 1;
  dp[s] = 1;
  for (int i = 0; i < n; ++i) {
    // s = s << 1 | (str[i] - '0');
    s <<= 1;
    s[0] = (int)(str[i] - '0');
  }
  
  printf("%d\n", Dfs(s));
  return 0;
}