Problem hidden
|This problem was hidden by Editorial Board member probably because it has incorrect language|version or invalid test data, or description of the problem is not clear.|

TWOOPERS - Hai thao tác trên chuỗi

Two operations on one string

John is given a string S. He is asked to do the following two operations in the given order to S:

  1. Choose one element of S, and replace it with any character he wants.
  2. Shift the string S, that means, he may choose a position k and shifts the whole string circularly so that k becomes be the first place of the new string.

John wants the result to be a specified string. It's up to you to tell him how many ways to transform S to a given string T.

Input

  • The input consists of two strings S and T in a line. Each string contains at most 100000 characters. Only capital letters will occur in the strings.
  • It is guaranteed that S and T have the same length.

Output

Only one number, the number of ways to transform S to T.

Example

Input
AHYANGYI YANGYIAH

Output
8

Output details
John can replace the first "A" with "A", or "H" with "H", etc. 
i.e. it is allowed to replace a chatacter with itself.
After that, there's one way to shift the string.

Input
VSUMSU MSUMSU

Output
2

Output details
John should replace the first "V" with "M". 
After that, he has two ways to shift the string (k=1 or k=4).

Được gửi lên bởi:VOJ Team
Ngày:2008-07-21
Thời gian chạy:0.400s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:VNOI Marathon '08 - Round 8/DivA
Problem Setter: Yang Yi

hide comments
2021-03-07 13:05:10
one hit không khó, bài này dùng Hash hơi dài nhưng khá dễ
2019-03-20 09:52:57
bài bảo chỉ thực hiện 2 thao tác kia 1 lần .. not vô hạn
2018-11-23 04:12:51
Z-function 1 hit AC 0.00s, code cho ai cần : https://ideone.com/eToJxm
2016-08-27 21:19:37 even when you try to hurt me...
mình dùng z function. không biết có đúng k. các bạn bị 60 có ai biết sai chỗ nào k vậy? mình tìm mãi k ra.....
2010-03-05 11:44:42 Tran Manh Chanh Quan
limit khủng thế này QHĐ sao nổi trời.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.