import
java.util.*;
public
class
Main {
public
static
int
findMinimumOperations(String s, String s1) {
int
n = s.length();
int
m = s1.length();
int
[] frequency =
new
int
[
26
];
for
(
int
i =
0
; i < n; i++) {
frequency[s.charAt(i) -
'a'
]++;
}
for
(
int
i =
0
; i < m; i++) {
if
(frequency[s1.charAt(i) -
'a'
] ==
0
) {
return
-
1
;
}
}
List<List<Integer>> indices =
new
ArrayList<>();
for
(
int
i =
0
; i <
26
; i++) {
indices.add(
new
ArrayList<Integer>());
}
for
(
int
i =
0
; i < n; i++) {
indices.get(s.charAt(i) -
'a'
).add(i);
}
int
ans =
2
;
int
last = indices.get(s1.charAt(
0
) -
'a'
).size() -
1
;
for
(
int
i =
1
; i < m; i++) {
int
ch = s1.charAt(i) -
'a'
;
int
it = binarySearchRight(indices.get(ch), last);
if
(it != indices.get(ch).size()) {
last = it;
}
else
{
ans++;
last = indices.get(ch).size();
}
}
return
ans;
}
public
static
int
binarySearchRight(List<Integer> arr,
int
x) {
int
left =
0
, right = arr.size();
while
(left < right) {
int
mid = (left + right) /
2
;
if
(arr.get(mid) <= x) {
left = mid +
1
;
}
else
{
right = mid;
}
}
return
left;
}
public
static
void
main(String[] args) {
String S1 =
"acebcd"
;
String S2 =
"acbcde"
;
int
ans = findMinimumOperations(S1, S2);
if
(ans == -
1
) {
System.out.println(
"NO"
);
}
else
{
System.out.println(
"YES"
);
System.out.println(ans);
}
}
}