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 Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;


public class Main {



	static int mod = 998244353;
	static HashMap<String,Long> dp = new HashMap();
	public static long solve(String s) {
		if (s.length() == 0) return 1;
		if (s.length() == 1) {
			return s.charAt(0) == '1' ? 2 : 1;
		}
		if (dp.containsKey(s)) {
			return dp.get(s);
		}
		long ret = (s.charAt(0) == '1' ? 2 : 1) * (solve(s.substring(1,s.length())));
		ret %= mod;
		for (int i = 0 ; i < s.length(); ++i) {
			int lst = i + 1;
			int len = i + 1;
			StringBuilder cur = new StringBuilder(s.substring(0, lst));
			while (lst + len - 1 < s.length()) {
				for (int k = lst , p = 0; k <= lst + len - 1 ; ++k, ++p) {
					if (s.charAt(k) == '0') {
						cur.setCharAt(p, '0');
					}
				}

				lst += len;
				ret += (1L*solve(cur.toString()) * solve(s.substring(lst,s.length())))%mod;
				ret %= mod;

			}
		}
		dp.put(s, ret);
		return ret;

	}
	public static void main(String[]args) throws Throwable {
		Scanner sc = new Scanner(System.in);
		System.out.println(solve(sc.next()));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}