#include <bits/stdc++.h>
using namespace std;
template <class T>
long long size(const T &x) {
  return x.size();
}
const int INF = 2147493647;
const double pi = acos(-1);
const double EPS = 1e-9;
int main() {
  string s, t;
  cin >> s >> t;
  set<char> r;
  for (long long i = (0); i < (s.size()); ++i) r.insert(s[i]);
  bool f = true;
  for (long long i = (0); i < (t.size()); ++i)
    if (r.find(t[i]) == r.end()) f = false;
  if (f)
    assert(0);
  else
    cout << -1 << endl;
}
