queue = new LinkedList<>();
Node node = new Node(String.valueOf(inStr),0);
queue.add(node);
vis.put(node.str,true);
while(queue.size() != 0){
node = queue.poll();
if(isOk(node.str)){
return node.step;
}
char[] str = node.str.toCharArray();
int step = node.step;
for(int i = 0;i=str.length || j==0 || str[i+j] != '*'){
continue;
}
str = swap(str,i,j);
node = new Node(String.valueOf(str),step+1);
if(!vis.containsKey(node.str)){
queue.add(node);
vis.put(node.str,true);
}
str = swap(str,i,j);
}
}
}
return -1;
}
public static char[] swap(char[] str,int i,int j){
char temp = str[i];
str[i] = str[j+i];
str[j+i] = temp;
return str;
}
public static boolean isOk(String str){
if(targetStr.equals(str)){
return true;
}else{
return false;
}
}
static class Node{
int step;
String str;
public Node(String str,int step){
this.str = str;
this.step = step;
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
inStr = sc.nextLine();
targetStr = sc.nextLine();
System.out.println(bfs());
}
}
```