Given are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.

* Let s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\ldots{s'}_i (the first i characters in s').

Constraints

* 1 \leq |s| \leq 10^5
* 1 \leq |t| \leq 10^5
* s and t consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:


s
t


Output

If there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print `-1`.

Examples

Input

contest
son


Output

10


Input

contest
programming


Output

-1


Input

contest
sentence


Output

33
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] s = scanner.next().toCharArray();
    char[] t = scanner.next().toCharArray();
    int N = s.length;

    int[][] table = new int[N][26];
    Arrays.fill(table[N - 1], -1);
    for (int i = 0; i < N; i++) if (table[N - 1][s[i] - 'a'] < 0) table[N - 1][s[i] - 'a'] = i;

    for (int i = N - 2; i >= 0; i--) {
      table[i] = Arrays.copyOf(table[i + 1], 26);
      table[i][s[i + 1] - 'a'] = i + 1;
    }

    long res = 0;
    int cur = N - 1;
    for (char c : t) {
      int next = table[cur][c - 'a'];
      if (next < 0) {
        System.out.println(-1);
        return;
      }
      res += next - cur;
      if (next <= cur) res += N;
      cur = next;
    }
    System.out.println(res);
  }
}
