You are given two strings S and P. Choose one or more of the starting positions where P occurs in S so that the product of the chosen positions is divisible by every natural number from 1 to 9. Count how many such choices exist.
Starting positions are counted with the first character of S as position 1. Occurrences of P may overlap. Two choices are different when the sets of chosen starting positions differ.
For example, if P = "a" and S = "aaaaaaa", the choices that satisfy the condition are {1, 2, 3, 4, 5, 6, 7}, {2, 3, 4, 5, 6, 7}, {3, 4, 5, 6, 7} and {1, 3, 4, 5, 6, 7}, so there are four of them.