#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll x, y, a, b;
  int main(){
  cin >> x >> y;
    a=x%10;
    b=y%10;
    if(x==y){
      cout << x <<  << endl;
    }
    if(a!=b){
    if(a>b){
        ll k=y-b+a;
        cout << k << endl;
    }
    else{
      cout << -1 << endl;
    }
    int a2=x%100-x%10;
    int b2=y%100-y%10;
    if(a2>b2){
      ll k2=y-a2-b2;
      cout << k2 << endl;
        int a3=x%10-x%10;
    int b3=y%10;

    int a4=x%10;
    int b4=y%10;

    int a5=x%10;
    int b5=y%10;

    int a6=x%10;
    int b6=y%10;

    int a7=x%10;
    int b7=y%10;

    int a8=x%10;
    int b8=y%10;

    int a9=x%10;
    int b9=y%10;

    int a10=x%10;
    int b10=y%10;
    }

    else{
      cout << -1 << endl;
    }


    }
  return 0;
  }