#include <bits/stdc++.h>
using namespace std; 
int main() {
  int A;
  int B;
  cin>>A>>B;
  int i=0;
  int j=B-A;
  int sum=0;
  int C=A;
  while(i<=j){
    A=C;
    int a=A%10;//A=12345の時5
    A/=10;//A=1234
    int b=A%10;
    A/=10;//A=123
    A/=10;//A=12
    int d=A%10;
    A/=10;//A=1
    int e=A;
    if(a==e&&b==d){
      sum+=1;
    }
    C++;
    i++;
  }
  cout<<sum<<endl;

}

#include<iostream>
using namespace std;

int main() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    int na = sa.length() + 1;
    int nb = sb.length() + 1;
    int nc = sc.length() + 1;

    int a = 0, b = 0, c = 0;
    char next = 'a', ans = 'A';
    while(a < na && b < nb && c < nc) {
        if (next == 'a') {
            next = sa[a];
            a++;
            ans = 'A';
        } else if (next == 'b') {
            next = sb[b];
            b++;
            ans = 'B';
        } else {
            next = sc[c];
            c++;
            ans = 'C';
        }
    }

    cout << ans << endl;

}