#include<cstdio> #include<cstdlib> //#define ll long long using namespace std; const int N=5e6; int sum[413]=//每一块分管i*N+1 ~ (i+1)*N { 753274,1459689,1736155,2442570,2736137,3442552,3733998, 4440413,4870362,5438525,6006688,6436637,7143052,7434498, 8140913,8434480,9140895,9417361,10123776,10538745,10538745, 10538745,10538745,10538745,10538745,10538745,10830191,11536606, 11966555,12534718,13102881,13532830,14239245,14530691,15237106, 15530673,16237088,16513554,17219969,17634938,18049907,18756322, 18756322,18756322,18756322,18756322,18756322,18756322,19186271, 19754434,20322597,20752546,21458961,21750407,22456822,22750389, 23456804,23733270,24439685,24854654,25269623,25976038,26252504, 26958919,26958919,26958919,26958919,26958919,26958919,26958919, 27527082,27957031,28663446,28954892,29661307,29954874,30661289, 30937755,31644170,32059139,32474108,33180523,33456989,34163404, 34456971,35163386,35163386,35163386,35163386,35163386,35163386, 35163386,35869801,36161247,36867662,37161229,37867644,38144110, 38850525,39265494,39680463,40386878,40663344,41369759,41663326, 42369741,42661187,43367602,43367602,43367602,43367602,43367602, 43367602,43367602,44074017,44367584,45073999,45350465,46056880, 46471849,46886818,47593233,47869699,48576114,48869681,49576096, 49867542,50573957,51003906,51572069,51572069,51572069,51572069, 51572069,51572069,51572069,52278484,52554950,53261365,53676334, 54091303,54797718,55074184,55780599,56074166,56780581,57072027, 57778442,58208391,58776554,59344717,59774666,59774666,59774666, 59774666,59774666,59774666,59774666,60481081,60896050,61311019, 62017434,62293900,63000315,63293882,64000297,64291743,64998158, 65428107,65996270,66564433,66994382,67700797,67992243,67992243, 67992243,67992243,67992243,67992243,67992243,68407212,69113627, 69390093,70096508,70390075,71096490,71387936,72094351,72524300, 73092463,73660626,74090575,74796990,75088436,75794851,76088418, 76088418,76088418,76088418,76088418,76088418,76088418,76088418, 76088418,76088418,76088418,76088418,76088418,76088418,76088418, 76088418,76088418,76088418,76088418,76088418,76088418,76088418, 76088418,76088418,76088418,76088418,76088418,76088418,76088418, 76088418,76088418,76088418,76088418,76088418,76088418,76088418, 76088418,76088418,76088418,76088418,76088418,76088418,76088418, 76088418,76088418,76088418,76088418,76088418,76088418,76088418, 76088418,76088418,76088418,76088418,76088418,76088418,76088418, 76088418,76088418,76088418,76088418,76088418,76088418,76088418, 76088418,76503387,77209802,77486268,78192683,78192683,78192683, 78192683,78192683,78192683,78192683,78760846,79190795,79897210, 80188656,80895071,81188638,81895053,82171519,82877934,83292903, 83707872,84414287,84690753,85397168,85690735,86397150,86397150, 86397150,86397150,86397150,86397150,86397150,87103565,87395011, 88101426,88394993,89101408,89377874,90084289,90499258,90914227, 91620642,91897108,92603523,92897090,93603505,93894951,94601366, 94601366,94601366,94601366,94601366,94601366,94601366,95307781, 95601348,96307763,96584229,97290644,97705613,98120582,98826997, 99103463,99809878,100103445,100809860,101101306,101807721,102237670, 102805833,102805833,102805833,102805833,102805833,102805833,102805833, 103512248,103788714,104495129,104910098,105325067,106031482,106307948, 107014363,107307930,108014345,108305791,109012206,109442155,110010318, 110578481,111008430,111008430,111008430,111008430,111008430,111008430, 111008430,111714845,112129814,112544783,113251198,113527664,114234079, 114527646,115234061,115525507,116231922,116661871,117230034,117798197, 118228146,118934561,119226007,119226007,119226007,119226007,119226007, 119226007,119226007,119640976,120347391,120623857,121330272,121623839, 122330254,122621700,123328115,123758064,124326227,124894390,125324339, 126030754,126322200,127028615,127322182,127322182,127322182,127322182, 127322182 }; bool check(int x) { int pre=x%10,nw; x/=10; while(x) { nw=x%10,x/=10; if(nw-pre<2 && pre-nw<2 ) return false; pre=nw; } return true; } int work(int l,int r) { int sm=0; for(int i=l;i<=r;i++) if(check(i)) sm++; return sm; } int main() { int a,b; scanf("%d%d",&a,&b); int p1=(a-1)/N,p2=(b-1)/N; int ans; if(p1==p2) ans=work(a,b); else { ans=work(a,(p1+1)*N); ans+=work(p2*N+1,b); ans+=sum[p2-1]-sum[p1];//p2要减去1,因为p2,p1两块都不完整,要单独一个个的算 } printf("%d ",ans); return 0; }