#include <bits/stdc++.h>
using namespace std;
int main() {
string s1, s2; cin>>s1>>s2;
// each char of s2 must present in s1 so that we can cnt how many times s2 is coming in s1.
// for that we will push char of both string in two different map(mp1 & mp) & if any char of s2 is
// not present in mp2 then we can say we will not get s2 in s1 for any no. of time.
unordered_map<char, int> mp1; // to store the char of s1
unordered_map<char, int> mp2; // to store the char of s2
for(int i=0; i<s1.size(); i++) mp1[s1[i]]++;
for(int i=0; i<s2.size(); i++) mp2[s2[i]]++;
int ans=1e9;
for(char ch='a'; ch<='z'; ch++) {
if(mp2.find(ch)!=mp2.end() && mp1.find(ch)==mp1.end())
{
ans=0;
break;
}
if(mp1.find(ch)!=mp1.end() && mp2.find(ch) !=mp2.end()) {
int cnt = mp1[ch] / mp2[ch];
ans=min(ans, cnt);
}
}
cout<<ans<<" ";
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCQoJc3RyaW5nIHMxLCBzMjsgICBjaW4+PnMxPj5zMjsKCgkvLyBlYWNoIGNoYXIgb2YgczIgbXVzdCBwcmVzZW50IGluIHMxIHNvIHRoYXQgd2UgY2FuIGNudCBob3cgbWFueSB0aW1lcyBzMiBpcyBjb21pbmcgaW4gczEuCgkvLyBmb3IgdGhhdCB3ZSB3aWxsIHB1c2ggY2hhciBvZiBib3RoIHN0cmluZyBpbiB0d28gZGlmZmVyZW50IG1hcChtcDEgJiBtcCkgJiBpZiBhbnkgY2hhciBvZiBzMiBpcwoJLy8gbm90IHByZXNlbnQgaW4gbXAyIHRoZW4gd2UgY2FuIHNheSB3ZSB3aWxsIG5vdCBnZXQgczIgaW4gczEgZm9yIGFueSBuby4gb2YgdGltZS4KCQoJdW5vcmRlcmVkX21hcDxjaGFyLCBpbnQ+IG1wMTsgIC8vIHRvIHN0b3JlIHRoZSBjaGFyIG9mIHMxCgl1bm9yZGVyZWRfbWFwPGNoYXIsIGludD4gbXAyOyAvL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