#include <bits/stdc++.h>
using namespace std;
int main() {
  string str1, str2;
  cin >> str1;
  cin >> str2;
  int j = 0;
  long int sum = 0;
  int flag = 0;
  for (int i = 0; i < (int)str2.size(); i++) {
    int local_sum = 0;
    for (;;) {
      if (str1[j] == str2[i]) {
        sum++;
        j = (j + 1) % (int)str1.size();
        cout << "a";
        break;
      }
      cout << "b";
      j = (j + 1) % (int)str1.size();
      sum++;
      local_sum++;
      if (local_sum == (int)str1.size()) {
        flag = 1;
        i = (int)str2.size();
        cout << "c";
        break;
      }
    }
  }
  if (flag == 1) {
    cout << "-1";
  } else {
    cout << sum;
  }
}
