program sub_string
    implicit none
    character(len=1000) s
    character(len=1000) t
    integer a, b, n, i, j, con, ans
    integer,allocatable :: x(:)

    read *,s
    read *,t

    a=len_trim(s)
    b=len_trim(t)
    n=a-b
    i=0
    allocate(x(n+1))

    do while(i<=n)
        con=0
        do j=1,b
            if(s(j+i:j+i)/=t(j:j))then
                con=con+1
            end if
        end do
        i=i+1
        x(i)=con
    end do  
    ans=minval(x)
    print *,ans
end program sub_string
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEs = internal global [1000 x i8] undef
@_QFEt = internal global [1000 x i8] undef
@_QFEx.0 = internal unnamed_addr global ptr null
@_QFEx.8 = internal unnamed_addr global i64 0
@_QQcl.21a29a951c434085c275ee6a6aef50c6 = linkonce constant [72 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_699/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.21a29a951c434085c275ee6a6aef50c6, i32 8)
  %3 = tail call i1 @_FortranAioInputAscii(ptr %2, ptr nonnull @_QFEs, i64 1000)
  %4 = tail call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.21a29a951c434085c275ee6a6aef50c6, i32 9)
  %6 = tail call i1 @_FortranAioInputAscii(ptr %5, ptr nonnull @_QFEt, i64 1000)
  %7 = tail call i32 @_FortranAioEndIoStatement(ptr %5)
  br label %8

8:                                                ; preds = %0, %8
  %9 = phi i64 [ 999, %0 ], [ %13, %8 ]
  %10 = getelementptr [1000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !3
  %12 = icmp eq i8 %11, 32
  %13 = add nsw i64 %9, -1
  %14 = icmp ne i64 %9, 0
  %15 = and i1 %12, %14
  br i1 %15, label %8, label %16

16:                                               ; preds = %8
  %17 = trunc i64 %9 to i32
  %18 = add i32 %17, 1
  br label %19

19:                                               ; preds = %16, %19
  %20 = phi i64 [ 999, %16 ], [ %24, %19 ]
  %21 = getelementptr [1000 x [1 x i8]], ptr @_QFEt, i64 0, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !3
  %23 = icmp eq i8 %22, 32
  %24 = add nsw i64 %20, -1
  %25 = icmp ne i64 %20, 0
  %26 = and i1 %23, %25
  br i1 %26, label %19, label %27

27:                                               ; preds = %19
  %28 = select i1 %12, i32 0, i32 %18
  %29 = trunc i64 %20 to i32
  %30 = add i32 %29, 1
  %31 = select i1 %23, i32 0, i32 %30
  %32 = sub i32 %28, %31
  %33 = add i32 %32, 1
  %34 = tail call i32 @llvm.smax.i32(i32 %33, i32 0)
  %35 = zext i32 %34 to i64
  %36 = shl nuw nsw i64 %35, 2
  %37 = tail call ptr @malloc(i64 %36)
  store ptr %37, ptr @_QFEx.0, align 8, !tbaa !7
  store i64 %35, ptr @_QFEx.8, align 8, !tbaa !7
  %.not122 = icmp slt i32 %32, 0
  br i1 %.not122, label %._crit_edge126, label %.lr.ph125

.lr.ph125:                                        ; preds = %27
  %38 = icmp sgt i32 %31, 0
  br i1 %38, label %.lr.ph.us.preheader, label %.lr.ph125.split

.lr.ph.us.preheader:                              ; preds = %.lr.ph125
  %39 = zext i32 %31 to i64
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %._crit_edge.us
  %.081123.us = phi i32 [ %50, %._crit_edge.us ], [ 0, %.lr.ph.us.preheader ]
  br label %40

40:                                               ; preds = %.lr.ph.us, %40
  %indvars.iv = phi i64 [ 1, %.lr.ph.us ], [ %indvars.iv.next, %40 ]
  %.0121.us = phi i32 [ 0, %.lr.ph.us ], [ %spec.select.us, %40 ]
  %41 = trunc i64 %indvars.iv to i32
  %42 = add i32 %.081123.us, %41
  %43 = sext i32 %42 to i64
  %44 = add nsw i64 %43, -1
  %45 = getelementptr [1000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %44
  %46 = add nsw i64 %indvars.iv, -1
  %47 = getelementptr [1000 x [1 x i8]], ptr @_QFEt, i64 0, i64 %46
  %48 = tail call i32 @_FortranACharacterCompareScalar1(ptr %45, ptr %47, i64 1, i64 1)
  %.not117.us = icmp ne i32 %48, 0
  %49 = zext i1 %.not117.us to i32
  %spec.select.us = add i32 %.0121.us, %49
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %39
  br i1 %exitcond.not, label %._crit_edge.us, label %40

._crit_edge.us:                                   ; preds = %40
  %50 = add i32 %.081123.us, 1
  %.unpack105.us = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %51 = sext i32 %50 to i64
  %52 = add nsw i64 %51, -1
  %53 = getelementptr i32, ptr %.unpack105.us, i64 %52
  store i32 %spec.select.us, ptr %53, align 4, !tbaa !3
  %.not.us = icmp sgt i32 %50, %32
  br i1 %.not.us, label %._crit_edge126.loopexit, label %.lr.ph.us

.lr.ph125.split:                                  ; preds = %.lr.ph125, %.lr.ph125.split
  %.081123 = phi i32 [ %54, %.lr.ph125.split ], [ 0, %.lr.ph125 ]
  %54 = add i32 %.081123, 1
  %55 = sext i32 %54 to i64
  %56 = add nsw i64 %55, -1
  %57 = getelementptr i32, ptr %37, i64 %56
  store i32 0, ptr %57, align 4, !tbaa !3
  %.not = icmp sgt i32 %54, %32
  br i1 %.not, label %._crit_edge126, label %.lr.ph125.split

._crit_edge126.loopexit:                          ; preds = %._crit_edge.us
  %.unpack100.unpack.unpack102.pre = load i64, ptr @_QFEx.8, align 8, !tbaa !7
  br label %._crit_edge126

._crit_edge126:                                   ; preds = %.lr.ph125.split, %._crit_edge126.loopexit, %27
  %.unpack100.unpack.unpack102 = phi i64 [ %.unpack100.unpack.unpack102.pre, %._crit_edge126.loopexit ], [ %35, %27 ], [ %35, %.lr.ph125.split ]
  %.unpack = phi ptr [ %.unpack105.us, %._crit_edge126.loopexit ], [ %37, %27 ], [ %37, %.lr.ph125.split ]
  store ptr %.unpack, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack100.unpack.unpack102, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %58 = call i32 @_FortranAMinvalInteger4(ptr nonnull %1, ptr nonnull @_QQcl.21a29a951c434085c275ee6a6aef50c6, i32 27, i32 0, ptr null)
  %59 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.21a29a951c434085c275ee6a6aef50c6, i32 28)
  %60 = call i1 @_FortranAioOutputInteger32(ptr %59, i32 %58)
  %61 = call i32 @_FortranAioEndIoStatement(ptr %59)
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputAscii(ptr, ptr, i64) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare i32 @_FortranACharacterCompareScalar1(ptr, ptr, i64, i64) local_unnamed_addr

declare i32 @_FortranAMinvalInteger4(ptr, ptr, i32, i32, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
