/* package whatever; // don't place package name! */

import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Pattern pat = Pattern.compile( ".*a.*?b.*" );
		boolean b;
		String text = "             a                      b                      ";
		Matcher m = pat.matcher( text );
		long t1 = System.currentTimeMillis();
		for ( int i=0; i<500000; i++ ) {
			b = m.matches();
		}
		long t2 = System.currentTimeMillis();
		System.out.print( t2 - t1 ) ;
	}
}