import java.io.*;
import java.util.*;
public class Main {
public static void main
(String[] args
) { InputReader in = new InputReader(inputStream);
OutputWriter out = new OutputWriter(outputStream);
TaskB solver = new TaskB();
solver.solve(in, out);
out.close();
}
}
class TaskB {
public void solve(InputReader in, OutputWriter out) {
System.
out.
println(calculateSum
("GAAAGGCCCCCCGGG",
"GAAAGGCCCCCCGGG")); // 1215 System.
out.
println(calculateSum
("GAAAGGCCCCCCGGG",
"GTTTGGCCCCCCGGG")); // 1080 }
long sum = 0;
for(int i=0;i<s.length();i++) {
for(int j=0;j<t.length();j++) {
sum += calculate(s,t);
t = (t.substring(1,t.length()) + t.charAt(0));
}
s = (s.substring(1,s.length()) + s.charAt(0));
}
return sum;
}
long sum = 0;
for(int i=0;i<s.length();i++) {
if(s.charAt(i) == t.charAt(i)) sum++;
}
return sum;
}
}
class InputReader {
tokenizer = null;
}
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
}
}
return tokenizer.nextToken();
}
public boolean hasNext() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
String line
= reader.
readLine(); if ( line == null ) {
return false;
}
}
}
return true;
}
public int nextInt() {
}
public long nextLong() {
return Long.
parseLong(next
()); }
public double nextDouble
() { return Double.
parseDouble(next
());} }
class OutputWriter {
}
public OutputWriter
(Writer writer
) { }
public void print
(Object...
objects) { for (int i = 0; i < objects.length; i++) {
if ( i != 0 ) {
writer.print(' ');
}
writer.print(objects[i]);
}
}
public void printLine
(Object...
objects) { print(objects);
writer.println();
}
public void close() {
writer.close();
}
}
aW1wb3J0IGphdmEuaW8uKjsKaW1wb3J0IGphdmEudXRpbC4qOwpwdWJsaWMgY2xhc3MgTWFpbiB7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgSW5wdXRTdHJlYW0gaW5wdXRTdHJlYW0gPSBTeXN0ZW0uaW47CiAgICAgICAgT3V0cHV0U3RyZWFtIG91dHB1dFN0cmVhbSA9IF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AgICByZXR1cm4gc3VtOwogICAgfQoKICAgIHByaXZhdGUgbG9uZyBjYWxjdWxhdGUoU3RyaW5nIHMsIFN0cmluZyB0KSB7CiAgICAgICAgbG9uZyBzdW0gPSAwOwogICAgICAgIGZvcihpbnQgaT0wO2k8cy5sZW5ndGgoKTtpKyspIHsKICAgICAgICAgICAgaWYocy5jaGFyQXQoaSkgPT0gdC5jaGFyQXQoaSkpIHN1bSsrOwogICAgICAgIH0KICAgICAgICByZXR1cm4gc3VtOwogICAgfQoKfQoKCmNsYXNzIElucHV0UmVhZGVyIHsKICAgIHB1YmxpYyBCdWZmZXJlZFJlYWRlciByZWFkZXI7CiAgICBwdWJsaWMgU3RyaW5nVG9rZW5pemVyIHRva2VuaXplcjsKICAgIHB1YmxpYyBJbnB1dFJlYWRlcihJbnB1dFN0cmVhbSBzdHJlYW0pIHsKICAgICAgICByZWFkZXIgPSBuZXcgQnVmZmVyZWRSZWFkZXIobmV3IElucHV0U3RyZWFtUmVhZGVyKHN0cmVhbSksIDMyNzY4KTsKICAgICAgICB0b2tlbml6ZXIgPSBudWxsOwogICAgfQogICAgcHVibGljIFN0cmluZyBuZXh0KCkgewogICAgICAgIHdoaWxlICh0b2tlbml6ZXIgPT0gbnVsbCB8fCAhdG9rZW5pemVyLmhhc01vcmVUb2tlbnMoKSkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdG9rZW5pemVyID0gbmV3IFN0cmluZ1Rva2VuaXplcihyZWFkZXIucmVhZExpbmUoKSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKElPRXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uKGUpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiB0b2tlbml6ZXIubmV4dFRva2VuKCk7CiAgICB9CiAgICBwdWJsaWMgYm9vbGVhbiBoYXNOZXh0KCkgewogICAgICAgIHdoaWxlICh0b2tlbml6ZXIgPT0gbnVsbCB8fCAhdG9rZW5pemVyLmhhc01vcmVUb2tlbnMoKSkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgU3RyaW5nIGxpbmUgPSByZWFkZXIucmVhZExpbmUoKTsKICAgICAgICAgICAgICAgIGlmICggbGluZSA9PSBudWxsICkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHRva2VuaXplciA9IG5ldyBTdHJpbmdUb2tlbml6ZXIobGluZSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKElPRXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uKGUpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgcHVibGljIGludCBuZXh0SW50KCkgewogICAgICAgIHJldHVybiBJbnRlZ2VyLnBhcnNlSW50KG5leHQoKSk7CiAgICB9CiAgICBwdWJsaWMgbG9uZyBuZXh0TG9uZygpIHsKICAgICAgICByZXR1cm4gTG9uZy5wYXJzZUxvbmcobmV4dCgpKTsKICAgIH0KICAgIHB1YmxpYyBkb3VibGUgbmV4dERvdWJsZSgpIHsgcmV0dXJuIERvdWJsZS5wYXJzZURvdWJsZShuZXh0KCkpO30KfQpjbGFzcyBPdXRwdXRXcml0ZXIgewogICAgcHJpdmF0ZSBmaW5hbCBQcmludFdyaXRlciB3cml0ZXI7CiAgICBwdWJsaWMgT3V0cHV0V3JpdGVyKE91dHB1dFN0cmVhbSBvdXRwdXRTdHJlYW0pIHsKICAgICAgICB3cml0ZXIgPSBuZXcgUHJpbnRXcml0ZXIobmV3IEJ1ZmZlcmVkV3JpdGVyKG5ldyBPdXRwdXRTdHJlYW1Xcml0ZXIob3V0cHV0U3RyZWFtKSkpOwogICAgfQogICAgcHVibGljIE91dHB1dFdyaXRlcihXcml0ZXIgd3JpdGVyKSB7CiA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