fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. using ll=long long;
  4. int main() {
  5. // your code goes here
  6. string s,t;
  7. cin>>s>>t;
  8. unordered_map<char,ll>x,y;
  9. for(auto c:s){
  10. x[c]++;
  11. }
  12. for(auto c:t){
  13. y[c]++;
  14. }
  15. ll ans=1e9;
  16. for(auto a:y)
  17. {
  18. if(x.find(a.first)==x.end()) {
  19. ans=0;
  20. break;
  21. }
  22. ans=min(ans,x[a.first]/a.second);
  23.  
  24. }
  25. cout<<ans<<endl;
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5288KB
stdin
mononom
mon
stdout
2