program main
    implicit none
    integer(4):: max_x=0, x=0
    integer(4):: n, i
    character(:),ALLOCATABLE:: s

    read*, n
    allocate(character(n):: s)

    read*, s

    do i=1, n
        if (s(i:i) == 'D') x=x-1
        if (s(i:i) == 'I') x=x+1

        max_x = max(max_x,x)
    end do

    print*, max_x
end program main
; 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"

@_QFEmax_x = internal unnamed_addr global i32 0
@_QFEx = internal unnamed_addr global i32 0
@_QQcl.a4e21cd56e7d1deba80022d0f46b3ba4 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7556/source.f\00"
@_QQcl.44 = linkonce constant [1 x i8] c"D"
@_QQcl.49 = linkonce constant [1 x i8] c"I"
@_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 i32, align 4
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.a4e21cd56e7d1deba80022d0f46b3ba4, i32 7)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 4)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i32, ptr %1, align 4, !tbaa !3
  %6 = call i32 @llvm.smax.i32(i32 %5, i32 0)
  %7 = zext i32 %6 to i64
  %8 = call ptr @malloc(i64 %7)
  %9 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.a4e21cd56e7d1deba80022d0f46b3ba4, i32 10)
  %10 = call i1 @_FortranAioInputAscii(ptr %9, ptr %8, i64 %7)
  %11 = call i32 @_FortranAioEndIoStatement(ptr %9)
  %12 = load i32, ptr %1, align 4, !tbaa !3
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %14 = zext i32 %12 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %._crit_edge7
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %._crit_edge7 ]
  %15 = add nsw i64 %indvars.iv, -1
  %16 = getelementptr [1 x i8], ptr %8, i64 %15
  %17 = call i32 @_FortranACharacterCompareScalar1(ptr %16, ptr nonnull @_QQcl.44, i64 1, i64 1)
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %22

19:                                               ; preds = %.lr.ph
  %20 = load i32, ptr @_QFEx, align 4, !tbaa !3
  %21 = add i32 %20, -1
  store i32 %21, ptr @_QFEx, align 4, !tbaa !3
  br label %22

22:                                               ; preds = %19, %.lr.ph
  %23 = call i32 @_FortranACharacterCompareScalar1(ptr %16, ptr nonnull @_QQcl.49, i64 1, i64 1)
  %24 = icmp eq i32 %23, 0
  %25 = load i32, ptr @_QFEx, align 4, !tbaa !3
  br i1 %24, label %26, label %._crit_edge7

26:                                               ; preds = %22
  %27 = add i32 %25, 1
  store i32 %27, ptr @_QFEx, align 4, !tbaa !3
  br label %._crit_edge7

._crit_edge7:                                     ; preds = %22, %26
  %28 = phi i32 [ %27, %26 ], [ %25, %22 ]
  %29 = load i32, ptr @_QFEmax_x, align 4, !tbaa !3
  %30 = call i32 @llvm.smax.i32(i32 %29, i32 %28)
  store i32 %30, ptr @_QFEmax_x, align 4, !tbaa !3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %14
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %._crit_edge7, %0
  %31 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.a4e21cd56e7d1deba80022d0f46b3ba4, i32 19)
  %32 = load i32, ptr @_QFEmax_x, align 4, !tbaa !3
  %33 = call i1 @_FortranAioOutputInteger32(ptr %31, i32 %32)
  %34 = call i32 @_FortranAioEndIoStatement(ptr %31)
  ret void
}

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

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

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

declare i32 @_FortranACharacterCompareScalar1(ptr, ptr, i64, i64) 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"}
