// Arup Guha
// 4/28/2022
// Code to accompany COP 3503 Final Exam Question #7

import java.util.*;

public class Q7 {

	final public static long MOD = 1000000007L;
	final public static long BASE = 29L;
	
	// Input.
	public static char[] s;
	public static char[] t;
	public static int m;
	public static int n;
	
	// Store prefix hash values here.
	public static long[] hash;
	
	public static long[] powBase;
	
	public static void main(String[] args) {
	
		// Read input. Assume both string contain lower case letters only.
		Scanner stdin = new Scanner(System.in);
		s = stdin.next().toCharArray();
		t = stdin.next().toCharArray();
		m = s.length;
		n = t.length;
		
		// Prefix calculation.
		hash = new long[m+1];
		for (int i=1; i<=m; i++) 
			hash[i] = (BASE*hash[i-1] + s[i-1]-'a'+1)%MOD;
		
		// Calculate base each power upto m under mod.
		powBase = new long[m+1];
		powBase[0] = 1;
		for (int i=0; i<m; i++)
			powBase[i+1] = (BASE*powBase[i])%MOD;
		
		// Go!
		System.out.println(go());
	}
	
	public static int go() {
	
		// Bounds for the binary search.
		int low = 0, high = m;
		
		// Keep going till we converge.
		while (low < high) {
		
			// This is what we have to try.
			int mid = (low+high+1)/2;
			
			// It works, so the answer is at least this big.
			if (contains(hash[mid],mid))
				low = mid;
				
			// It doesn't work so the answer is lower.
			else
				high = mid-1;
		}
		
		// Ta da!
		return low;
	}
	
	// Returns true iff the string with hashval of length len appears in t.
	public static boolean contains(long hashval, int len) {
		
		// Empty string is in everything.
		if (len == 0) return true;
	
		// Hash of first len letters of t.
		long myhash = 0;
		for (int i=0; i<len; i++)
			myhash = (BASE*myhash + t[i]-'a'+1)%MOD;
		
		// Roll hash.
		for (int i=len; i<=n; i++) {
		
			// Done!
			if (myhash == hashval && check(i-len, len)) return true;
			if (i == n) break;
			
			// Subtract out value of most significant letter.
			myhash = (myhash - (t[i-len]-'a'+1)*powBase[len-1])%MOD;
			if (myhash < 0) myhash += MOD;
			
			// Shift left and add in new letter.
			myhash = (BASE*myhash + t[i] -'a'+1 )%MOD;
		}
		
		// Never got a match.
		return false;
	}
	
	// Verifies a match found by hashing.
	public static boolean check(int start, int length) {
	
		// Try matching all of the letters starting here. Anything that doesn't match kills the match.
		for (int i=start; i<start+length; i++)
			if (t[i] != s[i-start])
				return false;
				
		// If we get here, it was a match.
		return true;
	}

}