#include <bits/stdc++.h>
int main(void) {
  std::string s, t;
  std::cin >> s >> t;
  int i = 0;
  int j = 0;
  int size = s.size();
  int sized = size * 100;
  int count = 0;
  for (; j < sized; j++) {
    if (t[i] == s[j % size]) {
      i++;
      if (i == t.size()) break;
      count = 0;
    } else
      count++;
    if (count == size) {
      std::cout << -1 << std::endl;
      return 0;
    }
  }
  if (j == sized) {
    std::cout << -1 << std::endl;
    return 0;
  }
  int r = j + 1;
  std::cout << r << std::endl;
  return 0;
}
