import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio; long solve(string N, long M) { long ans = 0; auto KK = N.length.to!int; for (int K = N.to!string.length.to!int; K > 0; K--) { auto dp = new long[][][](K/2+K%2+1, 2, 2); dp[0][0][1] = 1; foreach (i; 0..K/2+K%2) { foreach (j; 0..2) { foreach (h; 0..2) { int d = K == KK ? N[i+KK-K] - '0' : 9; foreach (k; 0..d+1) { if (i == 0 && k == 0) continue; (dp[i+1][j || (k < d)][h && d <= N[$-i-1] - '0'] += dp[i][j][h]) %= M; } } } } foreach (j; 0..2) { foreach (k; 0..2) { if (K == KK && j == 0 && k == 0) continue; (ans += dp[K/2+K%2][j][k]) %= M; } } //ans.writeln; } return ans; } void main() { auto N = readln.chomp; solve(N, 10^^9).writeln; solve(N, 10^^9+7).writeln; }