import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); char[] s = sc.next().toCharArray(); sc.close(); int ans = 0; int n = s.length - 1; int end = 1 << n; for (int i = 0; i < end; i++) { long val = 0; long now = s[0] - '0'; for (int j = 0; j < n; j++) { if ((i >> j & 1) == 1) { val += now; now = s[j + 1] - '0'; } else { now *= 10; now += s[j + 1] - '0'; } } val += now; if (isSosuu(val)) { ans++; } } System.out.println(ans); } static boolean isSosuu(long n) { if (n < 2) return false; if (n == 2) return true; long end = (int) Math.sqrt(n) + 1; for (int i = 2; i <= end; i++) { if (n % i == 0) { return false; } } return true; } }