process.stdin .resume ( ) ;
process.stdin .setEncoding ( 'utf8' ) ;
function countNumber( num) {
let count = 0 ;
while ( num > 0 ) {
const digit = num % 10 ;
// if (digit === 6) {
if ( digit === 3 || digit === 6 || digit === 9 ) {
count++;
}
num = Math .floor ( num / 10 ) ;
}
return count;
}
function countInRange( first, last) {
let count = 0 ;
for ( let i = first; i< last; i++ ) {
count+= countNumber( i)
}
return count
}
var remainder = ''
process.stdin .on ( 'data' , function ( chunk) {
const input = chunk.toString ( ) .split ( ' ' )
const maxNumber = input[ 1 ] .length
const minNumber = input[ 0 ] .length
console.log ( maxNumber, minNumber)
let result = 0
if ( maxNumber- minNumber > 1 ) {
for ( let i= minNumber+ 1 ; i<= maxNumber- 1 ; i++ ) {
console.log ( "i = " , i, Math .pow ( 10 , i- 1 ) )
result = ( Math .pow ( 10 , i- 1 ) + 9 * ( i- 1 ) * Math .pow ( 10 , i- 2 ) ) * 3
console.log ( "count after for 1" , result)
}
console.log ( "count after for" , result)
result+= countInRange( Number ( input[ 0 ] ) , Math .pow ( 10 , minNumber+ 1 ) )
console.log ( "count after min" , result)
result+= countInRange( Math .pow ( 10 , maxNumber- 1 ) , Number ( input[ 1 ] ) , )
console.log ( "count after max" , result)
} else {
result = countInRange( Number ( input[ 0 ] ) , Number ( input[ 1 ] ) )
}
// console.log(count)
// console.log(input[0], input[1])
// const result = countInRange(Number(input[0]), Number(input[1]))
console.log ( `result`, result)
} ) ;
cHJvY2Vzcy5zdGRpbi5yZXN1bWUoKTsKcHJvY2Vzcy5zdGRpbi5zZXRFbmNvZGluZygndXRmOCcpOwoKZnVuY3Rpb24gY291bnROdW1iZXIobnVtKSB7CiAgbGV0IGNvdW50ID0gMDsKICB3aGlsZSAobnVtID4gMCkgewogICAgY29uc3QgZGlnaXQgPSBudW0gJSAxMDsKICAgIC8vIGlmIChkaWdpdCA9PT0gNikgewogICAgaWYgKGRpZ2l0ID09PSAzIHx8IGRpZ2l0ID09PSA2fHwgZGlnaXQgPT09IDkpI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