import math,sequtils,strutils,unicode
proc powInt(n : int64, m : int64, k = 1_000_000_007):int64 =
    if m == 0:
        return 1
    elif m == 1:
        return (n mod k)
    if (m mod 2) == 0:
        return powInt((n*n) mod k,m div 2, k) mod k
    else:
        return (powInt((n*n) mod k,m div 2, k) * n) mod k
proc CToI(c : char):int =
    return( int(c) - int('0'))
var
    mod_Bill = 1_000_000_000
    mod_Bill_7 = 1_000_000_007
    N : string
    p : int64
let N1 = stdin.readline
proc kaibun(N : string):int64 =
    var x = N.len
    var
        X : seq[int64]
        i = 2
        a : int64
    a = parseBiggestInt(N[0..<((x + 1) div 2)])
    a += powInt(10, x div 2) - 2
    for i in 0..<x div 2:
        if N[i].CToI == N[^(i + 1)].CToI:
            discard
        elif N[i].CToI > N[^(i + 1)].CToI:
            a += 1
            break
        else:
            break
        if i == (x div 2) - 1:
            a += 1
    if x == 1:
        a+=1
    return a
p = kaibun(N1)
echo p mod mod_Bill
echo p mod mod_Bill_7