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

public class chemcode_ab implements Runnable {
	
	private void solve() throws IOException {
		String s = in.next();
		int n = in.nextInt();
		String[] e = new String[n];
		for (int i = 0; i < n; ++i) {
			e[i] = in.next();
		}
		
		int[] D = new int[s.length() + 1];
		Arrays.fill(D, INF);
		D[0] = 0;
		for (int i = 0; i < D.length; ++i) {
			int d = D[i];
			for (int k = 0; k < n; ++k) {
				int j = i;
				for (int l = 0; l < e[k].length(); ++l) {
					if (j < s.length() && s.charAt(j) == e[k].charAt(l)) {
						++j;
					}
					D[j] = Math.min(D[j], d + 1);
				}
			}
		}
		
		if (D[s.length()] < INF) {
			out.println(D[s.length()]);
		} else {
			out.println(-1);
		}
		
	}
	
	final int INF = (int)1e9;
	
	final String FILE_NAME = "chemcode";

	SimpleScanner in;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new SimpleScanner(new FileReader(FILE_NAME + ".in"));
			out = new PrintWriter(FILE_NAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	public static void main(String[] args) {
		new Thread(new chemcode_ab()).start();
	}

	class SimpleScanner extends BufferedReader {

		private StringTokenizer st;
		private boolean eof;

		public SimpleScanner(Reader a) {
			super(a);
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(readLine());
				} catch (Exception e) {
					eof = true;
					return "";
				}
			}
			return st.nextToken();
		}

		boolean seekEof() {
			String s = next();
			if ("".equals(s) && eof)
				return true;
			st = new StringTokenizer(s + " " + st.toString());
			return false;
		}

		private String cnv(String s) {
			if (s.length() == 0)
				return "0";
			return s;
		}

		int nextInt() {
			return Integer.parseInt(cnv(next()));
		}

		double nextDouble() {
			return Double.parseDouble(cnv(next()));
		}

		long nextLong() {
			return Long.parseLong(cnv(next()));
		}
	}
}