11426 - DS QUIZ3(1)   

Description

Given several inorder and preorder traversal sequences of a binary tree,

write a program to construct trees and output the number of leaf nodes.

Each node is represented by a 32-bit integer.

Time limit: 1sec.

Input

The input is the inorder and preorder traversal sequences of a binary tree.

In each test case, there are 2 lines.

The inorder traversal sequence of the tree is in the first line, and the preorder one is in the second.

 

Note:The total number of nodes in a tree will not exceed 20000.

Output

For each tree, please output the number of leaf nodes in a line.

Sample Input  Download

Sample Output  Download

Tags




Discuss