#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  long long now = 0;
  long long tSize = t.size();
  long long count = 0;
  s += s;
  for (int i = 0; true; i++) {
    for (char c : s) {
      count++;
      if (t[now] == c) {
        now++;
        if (tSize <= now) {
          cout << count << endl;
          return 0;
        }
      }
    }
    if (now == 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
