package no315; import java.io.FileNotFoundException; import java.util.Scanner; public class Main { public static long MOD = 1000000007; public static long stime; public static void main(String[] args) throws FileNotFoundException { Scanner sc = new Scanner(System.in); //Scanner sc = new Scanner(new File("in.txt")); stime = System.nanoTime(); String a = sc.next(); String b = sc.next(); int zeros = sc.next().length() - 1; long bb = aho(b,zeros); char[] as = a.toCharArray(); for(int i=as.length-1;i>=0;i--) { if (as[i] >= '1') { as[i]--; break; } as[i] = '9'; } long aa = aho(String.valueOf(as),zeros); System.out.println((bb + MOD - aa) % MOD); } public static void lap() { System.out.println((System.nanoTime() - stime) / 1000000); } public static boolean useNaive = false; public static long aho(String ss,int zeros) { if (useNaive && ss.length() <= 5) { return naiveAho(Integer.parseInt(ss), zeros); } char[] s = ss.toCharArray(); int n = Math.max(0,s.length - 3 - zeros); int[][][] dp = new int[2][4][n+1]; dp[1][0][0] = 1; for(int i=0;i= MOD) { dp[nlarge][nj][i+1] -= MOD; } } } } } long ans = 0; int max = 1000; int step = 8; for(int i=0;i 0) { int d = x % 10; sum += d; if (d == 3) { three = true; break; } x /= 10; } for(int large=0;large<2;large++) { if (large == 1 && i > tail) { continue; } for(int j=0;j<4;j++) { if (j == 3 || three || (j+sum)%3==0) { if (dp[large][j][n] > 0) { // System.out.println(i + "," + large + "," + j + "," + n); } ans += dp[large][j][n]; } } } } return ans % MOD; } public static long naiveAho(int max,int zeros) { long ans = 0; int step = 8; for(int i=0;i 0) { int d = x % 10; if (d == 3) { three = true; break; } x /= 10; } if (i % 3 == 0 || three) { ans++; } } return ans; } }