A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that walrus erase several letters from this string in order to get a new word s2. It is considered that when Fangy erases some letter, there's no whitespace formed instead of the letter. That is, the string remains unbroken and it still only consists of lowercase Latin letters.

For example, the heading is "abc". If we take two such headings and glue them one to the other one, we get "abcabc". If we erase the letters on positions 1 and 5, we get a word "bcac".

Which least number of newspaper headings s1 will Fangy need to glue them, erase several letters and get word s2?

Input

The input data contain two lines. The first line contain the heading s1, the second line contains the word s2. The lines only consist of lowercase Latin letters (1 ≤ |s1| ≤ 104, 1 ≤ |s2| ≤ 106).

Output

If it is impossible to get the word s2 in the above-described manner, print "-1" (without the quotes). Otherwise, print the least number of newspaper headings s1, which Fangy will need to receive the word s2.

Examples

Input

abc
xyz


Output

-1


Input

abcd
dabc


Output

2
import java.io.*;
import java.math.BigInteger;
import java.util.*;

/**
 * User: Sasha
 * Date: 24.02.11
 * Time: 21:45
 */
public class Main implements Runnable {
    private static BufferedScanner sc = new BufferedScanner();
    private static BufferedWriter out = new BufferedWriter(new PrintWriter(System.out));

    private void fill(StringBuffer a, int []ac) {
        for (int i = 0; i < a.length(); ++i) {
            ac[a.charAt(i) - 'a']++;
        }
    }

    private int bs(int a[], int ka) {
        int L = 0, R = a.length, M = R;
        int res = R;
        while (L < R) {
            M = (L + R) >> 1;
            if (a[M] >= ka) {
                res = M;
                R = M;
            } else {
                L = M + 1;
            }
        }
        return res;
    }

    public void solve() throws IOException {
        StringBuffer a = new StringBuffer(sc.next());
        StringBuffer b = new StringBuffer(sc.next());

        int ac[] = new int[26];
        int bc[] = new int[26];

        fill(a, ac);
        fill(b, bc);

        int res = 0;

        for (int i = 0; i < ac.length; ++i) {
            if (ac[i] == 0 && bc[i] > 0) {
                res = -1;
            }
        }

        if (res == -1) {
            System.out.println(res);
            return;
        }

        int [][]arr = new int[26][];
        int ac2[] = new int[26];
        for (int i = 0; i < a.length(); ++i) {
            int ind = a.charAt(i) - 'a';
            if (arr[ind] == null) {
                arr[ind] = new int[ac[ind]];
            }
            arr[ind][ac2[ind]] = i;
            ac2[ind]++;
        }

        int ka = 0;
        int n = a.length();
        res = 1;
        for (int i = 0; i < b.length(); ++i) {
            int ind = b.charAt(i) - 'a';

            if (ka == n) {
                ka = 0;
                ++res;
            }

            int maxIndex = bs(arr[ind], ka);
            if (maxIndex == arr[ind].length) {
                ++res;
                ka = 0;
                maxIndex = bs(arr[ind], ka);
            }
            ka = arr[ind][maxIndex] + 1;


        }

        System.out.println(res);

        System.out.flush();

    }

    public void run() {
        try {
            solve();
        } catch(IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String args[]) {
        new Thread(null, new Main(), "ACM-solution", 1<<22).start();
    }

    private static class BufferedScanner {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer = new StringTokenizer("");

        public BufferedScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        public BufferedScanner(Reader r) {
            bufferedReader = new BufferedReader(r);
        }

        public BufferedScanner(InputStream stream) {
            bufferedReader = new BufferedReader(new InputStreamReader(stream));
        }

        public boolean hasNext() throws IOException {
            boolean answer = true;
            while (!stringTokenizer.hasMoreElements()) {
                String nextLine = bufferedReader.readLine();
                if (nextLine != null) {
                    stringTokenizer = new StringTokenizer(nextLine);
                } else {
                    answer = false;
                    break;
                }
            }
            return answer;
        }

        public String next() throws IOException {
            if (hasNext()) {
                return stringTokenizer.nextToken();
            }
            throw new NoSuchElementException();
        }

        public Integer nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public Integer[] nextInts(int n) throws IOException {
            Integer arr[] = new Integer[n];
            for (int i = 0; i < n; ++i) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public Double[] nextDoubles(int n) throws IOException {
            Double arr[] = new Double[n];
            for (int i = 0; i < n; ++i) {
                arr[i] = nextDouble();
            }
            return arr;
        }

        public Long[] nextLongs(int n) throws IOException {
            Long arr[] = new Long[n];
            for (int i = 0; i < n; ++i) {
                arr[i] = nextLong();
            }
            return arr;
        }

        public String[] nextStrings(int n) throws IOException {
            String arr[] = new String[n];
            for (int i = 0; i < n; ++i) {
                arr[i] = next();
            }
            return arr;
        }
    }
}
