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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 *
 * @author evgeny11
 */
public class C {

    public static void main(String[] args){

        
        /**
        * InputC parameters
        */
        InputC in=new InputC();
        /**
        * Get parameters
        */
        char[] s1=in.getLine().toCharArray();
        char[] s2=in.getLine().toCharArray();
        /**
        * Close stream
        */
        in.close();
        /**
        * Main part
        */
        
        int n=code('z')+1;
        int[] count=new int[n];
        
        for(int i=0;i<s1.length;i++){
            count[code(s1[i])]++;
        }
        int[][] ind=new int[n][];
        for(int i=0;i<n;i++){
            ind[i]=new int[count[i]];
        }
        Arrays.fill(count, 0);
        for(int i=0;i<s1.length;i++){
            int c=code(s1[i]);
            ind[c][count[c]]=i;
            count[c]++;
        }
        int res=1;
        int currInd=0;
        for(int i=0;i<s2.length;i++){
            int c=code(s2[i]);
            int ii=findInd(currInd,ind[c]);
            if(ii<0){
                res=-1;
                break;
            }
            if(ii<currInd){
                res++;
            }
//          print(new Character(s2[i]).toString());
//          print(" ");
//          print(currInd);
//          print(" ");
//          println(ii);
            currInd=(ii+1);
            if(ii>s1.length){
                ii%=s1.length;
                res++;
            }
        }
        
        println(res);
    }
    
    private static int findInd(int curr,int[] ind){
        if(ind.length==0) return -1;
        int i1=0;
        int i2=ind.length-1;
        while(i1<=i2){
            int ii=(i2+i1)/2;
            if(ind[ii]<curr){
                i1=ii+1;
                continue;
            } else {
                if(ii>0){
                    if(ind[ii-1]<curr)
                        return ind[ii];
                } else {
                    return ind[ii];
                }
                i2=ii-1;
            }
        }
        return ind[0];
    }
    
    private static int code(char c){
        return (int)(c-'a');
    }


    private static void println(double x){
        System.out.println(Double.toString(x));
    }

    private static void println(long x){
        System.out.println(Long.toString(x));
    }

    private static void println(int x){
        System.out.println(Integer.toString(x));
    }

    private static void println(String str){
        System.out.println(str);
    }
    
    private static void print(double x){
        System.out.print(Double.toString(x));
    }

    private static void print(long x){
        System.out.print(Long.toString(x));
    }

    private static void print(int x){
        System.out.print(Integer.toString(x));
    }

    private static void print(String str){
        System.out.print(str);
    }
}   

class InputC{
    BufferedReader in;
    public InputC(){
        in = new BufferedReader(new InputStreamReader(System.in));
        if(in==null) exit("Cannot open stream");
    } 

    public void close(){
        if(in!=null){
            try {
                in.close();
            } catch (IOException ex) {
                exit("Cannot close the stream");
            }
        }
    }

    public String getLine(){
        try {
            return in.readLine();
        } catch (IOException ex) {
            exit("Cannot read line");
        }
        return null;
    }

    public int getInt(){
        return Integer.parseInt(getLine());
    }

    public double getDouble(){
        return Double.parseDouble(getLine());
    }

    public long getLong(){
        return Long.parseLong(getLine());
    }

    public int[] getIntArr(){
        String[] inp=getLine().split("\\s");
        int[] res=new int[inp.length];
        for(int i=0;i<inp.length;i++){
            res[i]=Integer.parseInt(inp[i]);
        }
        return res;
    }

    public long[] getLongArr(){
        String[] inp=getLine().split("\\s");
        long[] res=new long[inp.length];
        for(int i=0;i<inp.length;i++){
            res[i]=Long.parseLong(inp[i]);
        }
        return res;
    }

    public double[] getDobleArr(){
        String[] inp=getLine().split("\\s");
        double[] res=new double[inp.length];
        for(int i=0;i<inp.length;i++){
            res[i]=Double.parseDouble(inp[i]);
        }
        return res;
    }

    private void exit(String message){
        System.out.println("Error "+message);
        System.exit(1);
    }
}
