#include <bits/stdc++.h>
using namespace std;

#define ll long long
const int N = 200001;
const int inf = 1e9 + 7;
int br1[26], br2[26];

void solve() {
    string t, s;
    cin >> t >> s;
    for (int i = 0; i < t.size(); i++)
        br1[t[i] - 'a']++;
    for (int i = 0; i < s.size(); i++)
        br2[s[i] - 'a']++;
    if (br2[0] == s.size()) {
        cout << max(br1[0] - br2[0] + 1, 0) << endl;
        return;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}