#import <stdio.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
int main() {
    int n;
    char S[200];
    scanf("%d %s", &n, S);
    int x=0;
    int max=0;
    for (int a=0;a<n;a++){
        if (S[a]=='I') {
            x++;
            max = MAX(max,x);
            continue;
        }
        x--;
    }
    printf("%d", max);
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_845/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_845/source.m"
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"

@.str = private unnamed_addr constant [6 x i8] c"%d %s\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
  %n = alloca i32, align 4
  %S = alloca [200 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
  call void @llvm.lifetime.start.p0(i64 200, ptr nonnull %S) #4
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n, ptr noundef nonnull %S)
  %0 = load i32, ptr %n, align 4, !tbaa !5
  %cmp14 = icmp sgt i32 %0, 0
  br i1 %cmp14, label %for.body.preheader, label %for.cond.cleanup

for.body.preheader:                               ; preds = %entry
  %wide.trip.count = zext i32 %0 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %1 = icmp eq i32 %0, 1
  br i1 %1, label %for.cond.cleanup.loopexit.unr-lcssa, label %for.body.preheader.new

for.body.preheader.new:                           ; preds = %for.body.preheader
  %unroll_iter = and i64 %wide.trip.count, 4294967294
  br label %for.body

for.cond.cleanup.loopexit.unr-lcssa.loopexit:     ; preds = %for.inc.1
  %2 = add nsw i32 %x.1.1, 1
  br label %for.cond.cleanup.loopexit.unr-lcssa

for.cond.cleanup.loopexit.unr-lcssa:              ; preds = %for.cond.cleanup.loopexit.unr-lcssa.loopexit, %for.body.preheader
  %max.1.lcssa.ph = phi i32 [ undef, %for.body.preheader ], [ %max.1.1, %for.cond.cleanup.loopexit.unr-lcssa.loopexit ]
  %indvars.iv.unr = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next.1, %for.cond.cleanup.loopexit.unr-lcssa.loopexit ]
  %max.016.unr = phi i32 [ 0, %for.body.preheader ], [ %max.1.1, %for.cond.cleanup.loopexit.unr-lcssa.loopexit ]
  %x.015.unr = phi i32 [ 1, %for.body.preheader ], [ %2, %for.cond.cleanup.loopexit.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %for.cond.cleanup, label %for.body.epil

for.body.epil:                                    ; preds = %for.cond.cleanup.loopexit.unr-lcssa
  %arrayidx.epil = getelementptr inbounds [200 x i8], ptr %S, i64 0, i64 %indvars.iv.unr
  %3 = load i8, ptr %arrayidx.epil, align 1, !tbaa !9
  %cmp1.epil = icmp eq i8 %3, 73
  %cond.epil = call i32 @llvm.smax.i32(i32 %max.016.unr, i32 %x.015.unr)
  %max.1.epil = select i1 %cmp1.epil, i32 %cond.epil, i32 %max.016.unr
  br label %for.cond.cleanup

for.cond.cleanup:                                 ; preds = %for.body.epil, %for.cond.cleanup.loopexit.unr-lcssa, %entry
  %max.0.lcssa = phi i32 [ 0, %entry ], [ %max.1.lcssa.ph, %for.cond.cleanup.loopexit.unr-lcssa ], [ %max.1.epil, %for.body.epil ]
  %call6 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %max.0.lcssa)
  call void @llvm.lifetime.end.p0(i64 200, ptr nonnull %S) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
  ret i32 0

for.body:                                         ; preds = %for.inc.1, %for.body.preheader.new
  %indvars.iv = phi i64 [ 0, %for.body.preheader.new ], [ %indvars.iv.next.1, %for.inc.1 ]
  %max.016 = phi i32 [ 0, %for.body.preheader.new ], [ %max.1.1, %for.inc.1 ]
  %x.015 = phi i32 [ 0, %for.body.preheader.new ], [ %x.1.1, %for.inc.1 ]
  %niter = phi i64 [ 0, %for.body.preheader.new ], [ %niter.next.1, %for.inc.1 ]
  %arrayidx = getelementptr inbounds [200 x i8], ptr %S, i64 0, i64 %indvars.iv
  %4 = load i8, ptr %arrayidx, align 2, !tbaa !9
  %cmp1 = icmp eq i8 %4, 73
  br i1 %cmp1, label %if.then, label %if.end

if.then:                                          ; preds = %for.body
  %inc = add nsw i32 %x.015, 1
  %cond = call i32 @llvm.smax.i32(i32 %max.016, i32 %inc)
  br label %for.inc

if.end:                                           ; preds = %for.body
  %dec = add nsw i32 %x.015, -1
  br label %for.inc

for.inc:                                          ; preds = %if.end, %if.then
  %x.1 = phi i32 [ %inc, %if.then ], [ %dec, %if.end ]
  %max.1 = phi i32 [ %cond, %if.then ], [ %max.016, %if.end ]
  %indvars.iv.next = or i64 %indvars.iv, 1
  %arrayidx.1 = getelementptr inbounds [200 x i8], ptr %S, i64 0, i64 %indvars.iv.next
  %5 = load i8, ptr %arrayidx.1, align 1, !tbaa !9
  %cmp1.1 = icmp eq i8 %5, 73
  br i1 %cmp1.1, label %if.then.1, label %if.end.1

if.end.1:                                         ; preds = %for.inc
  %dec.1 = add nsw i32 %x.1, -1
  br label %for.inc.1

if.then.1:                                        ; preds = %for.inc
  %inc.1 = add nsw i32 %x.1, 1
  %cond.1 = call i32 @llvm.smax.i32(i32 %max.1, i32 %inc.1)
  br label %for.inc.1

for.inc.1:                                        ; preds = %if.then.1, %if.end.1
  %x.1.1 = phi i32 [ %inc.1, %if.then.1 ], [ %dec.1, %if.end.1 ]
  %max.1.1 = phi i32 [ %cond.1, %if.then.1 ], [ %max.1, %if.end.1 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %for.cond.cleanup.loopexit.unr-lcssa.loopexit, label %for.body
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
