// Arup Guha
// 1/30/2018
// Solution to 2017 MCPC Problem F: Orderly Class

import java.util.*;

public class orderly {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		char[] s1 = stdin.next().toCharArray();
		char[] s2 = stdin.next().toCharArray();
		int n = s1.length;

		int i = 0, j = n-1;

		// Guaranteed to be unequal so this is safe.
		while (s1[i] == s2[i]) i++;
		while (s1[j] == s2[j]) j--;

		// See if these "different" sections are reverses of each other.
		boolean flippable = true;
		for (int a=i, b=j; a<=j; a++,b--) {
			if (s1[a] != s2[b]) {
				flippable = false;
				break;
			}
		}

		// Initial result based on whether the middle is flippable.
		int res = flippable ? 1 : 0;

		// Here we add results.
		if (flippable) {

			// Move to previous slots.
			i--;
			j++;

			// Walk back out as far as you can, grabbing matches.
			while (i >= 0 && j < n && s1[i] == s2[j]) {
				res++;
				i--;
				j++;
			}
		}

		// Ta da!
		System.out.println(res);
	}
}