import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); String A = sc.next(); String B = sc.next(); long ans = 0; long t = 0; for(int i = 1; i < A.length(); i++) { if((A.charAt(i) == '2') && (A.charAt(i - 1) == '1')) t++; } ans = (func(B) - func(A)) + t + (func2(B) - func2(A)); System.out.println(ans); } public static long func(String X) { int len = X.length(); long[][][][] dp = new long[len][8][10][2]; int first = Integer.parseInt(String.valueOf(X.charAt(0))); for(int i = 0; i < first; i++) { dp[0][0][i][1] = 1; } dp[0][0][first][0] = 1; for(int i = 1; i < len; i++) { int d = Integer.parseInt(String.valueOf(X.charAt(i))); for(int j = 0; j < 8; j++) { for(int l = 0; l <= d; l++) { if(l == d) { if(l == 2) { dp[i][j + 1][l][0] += dp[i - 1][j][1][0]; } else { dp[i][j][l][0] += dp[i - 1][j][1][0]; } } else { if(l == 2) { dp[i][j + 1][l][1] += dp[i - 1][j][1][0]; } else { dp[i][j][l][1] += dp[i - 1][j][1][0]; } } } for(int l = 0; l <= 9; l++) { if(l == 2) { dp[i][j + 1][l][1] += dp[i - 1][j][1][1]; } else { dp[i][j][l][1] += dp[i - 1][j][1][1]; } } for(int k = 0; k <= 9; k++) { if(k != 1) { for(int l = 0; l <= d; l++) { if(l == d) { dp[i][j][l][0] += dp[i - 1][j][k][0]; } else { dp[i][j][l][1] += dp[i - 1][j][k][0]; } } for(int l = 0; l <= 9; l++) { dp[i][j][l][1] += dp[i - 1][j][k][1]; } } } } } long ret = 0; for(int j = 1; j < 8; j++) { for(int k = 0; k <= 9; k++) { for(int l = 0; l < 2; l++) { ret += dp[len - 1][j][k][l]; } } } return ret; } public static long func2(String X) { int len = X.length(); long ret = 0; for(int i = 1; i < len; i++) { if(i == 1) { ret++; } else { ret += ((long)Math.pow(10, i - 2)); } } int first = Integer.parseInt(String.valueOf(X.charAt(0))); if(first == 2) { int last = Integer.parseInt(String.valueOf(X.charAt(len - 1))); long t = Long.parseLong(X.substring(1, len - 1)); if(last < 2) { ret += t; } else { ret += (t + 1); } } if(first > 2) { ret += ((long)Math.pow(10, len - 2)); } if(X.equals("1")) { ret = 0; } else { if(len == 1) ret = 1; } return ret; } }