#include <bits/stdc++.h>
using namespace std;
char s[200001], t[200001];
int dls, dlt, wyn[200001];
vector<int> ds[30], dt[30];
int main() {
  scanf(" %s %s", s, t);
  dls = 0;
  while (s[dls]) {
    s[dls] -= 'a';
    ds[s[dls]].push_back(dls);
    dls++;
  }
  dlt = 0;
  while (t[dlt]) {
    t[dlt] -= 'a';
    dt[t[dlt]].push_back(dlt);
    dlt++;
  }
  int pre = 0;
  for (int i = 0; i < dls; i++) {
    int ak = s[i];
    int p = -1, k = dt[ak].size();
    while (p + 1 < k) {
      int m = (p + k) / 2;
      if (dt[ak][m] <= pre)
        p = m;
      else
        k = m;
    }
    if (p == -1) {
      printf("NO\n");
      return 0;
    }
    wyn[i] = dt[ak][p];
    if (dt[ak][p] == pre) pre++;
  }
  pre = dlt - 1;
  for (int i = dls - 1; i >= 0; i--) {
    int ak = s[i];
    int p = -1, k = dt[ak].size();
    while (p + 1 < k) {
      int m = (p + k) / 2;
      if (dt[ak][m] < pre)
        p = m;
      else
        k = m;
    }
    if (k == dt[ak].size() || wyn[i] < dt[ak][k]) {
      printf("NO\n");
      return 0;
    }
    if (dt[ak][k] == pre) pre--;
  }
  printf("YES\n");
}
