A,B = map(int,input().split()) ans = 0 def is_multi3(x): return x%3 == 0 def is_in3(x): return '3' in list(str(x)) for i in range(A,B+1): if is_multi3(i): ans += 1 continue if is_in3(i): ans +=1 print(ans)