#include <bits/stdc++.h>
using namespace std;
vector<int> prefix_function(const string& s)
{
vector<int> p(s.size());
for (int i = 1; i < s.size(); i++)
{
int l = p[i - 1];
while (l > 0 && s[i] != s[l])
l = p[l - 1];
p[i] = l + (s[i] == s[l]);
}
return p;
}
int main()
{
string p, r;
cin >> p >> r;
reverse(p.begin(), p.end());
reverse(r.begin(), r.end());
vector<int> pf = prefix_function(p + '$' + r);
int pos = r.size() - 1;
int ans = 0;
while (pos >= 0)
{
pos -= pf[p.size() + 1 + pos];
ans++;
}
cout << ans << "\n";
return 0;
}