/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static boolean isPrime(int num) {
        if (num < 2)
            return false;

        for (int i = 2; i * i <= num; i++) {
            if (num % i == 0)
                return false;
        }

        return true;
    }
    
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		String s = "11375";
		
		int N = s.length();
		
		int[] dp = new int[N];
		
		if(isPrime(Integer.parseInt(s.substring(0,1)))){
			dp[0] = 1;
		}
		
		
		for(int i = 1; i < N; i++){
		
			for(int j = i; j >= Math.max(0, i - 6); j--){
				if (s.charAt(j) == '0') continue;
				int num = Integer.parseInt(s.substring(j, i + 1));
				if(isPrime(num)){
					if(j == 0){
						dp[i] += 1;
					}else{
					dp[i] += dp[j-1];	
					}
		}
		}
		}
		
		System.out.println(dp[N-1]);
	}
}