/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		String s = "mononom";
		String t = "mon";
		s = "aaaaaaaaaabbbbbbbbbb";
		t = "aaaaabbbbb";
		
		System.out.println(helper(s,t));
	}
	static int helper(String s, String t){
		HashMap<Character,Integer> map1 = new HashMap<>();
		HashMap<Character,Integer> map2 = new HashMap<>();
		for(int i=0;i<s.length();i++){
			char c = s.charAt(i);
			map1.put(c, map1.getOrDefault(c,0)+1);
		}
		for(int i=0;i<t.length();i++){
			char c = t.charAt(i);
			map2.put(c, map2.getOrDefault(c,0)+1);
		}
		int ans = Integer.MAX_VALUE;
		for(int i=0;i<t.length();i++){
			char c = t.charAt(i);
			if(map1.containsKey(c)){
				ans = Math.min(ans, map1.get(c)/map2.get(c));
			} else {
				return 0;
			}
		}
		return ans;
		
	}
}