program main
  implicit none
  integer(8) N, i ,score, saishozantei!暫定トップ
  integer(8) lefts !左側の#
  integer(8) rightd !右側の.
  character(2*(10**5)) S
  read(*, *) N
  read(*, *) S
  lefts = 0
  rightd = 0
  !#の数
  do i = 1,N
    if (S(i:i) == '.') then
      rightd = rightd + 1
    end if
  end do
  saishozantei = rightd
  do i = 1,N
    if (S(i:i) == '#') then
      lefts = lefts + 1
    else
      rightd = rightd - 1
    end if
    score = lefts + rightd
    saishozantei = min(saishozantei,score)
  end do
  write(*,'(i0)') saishozantei
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"

@_QFEs = internal global [200000 x i8] undef
@_QQcl.fce0759fc1936aa37475bd94083fd5ca = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4437/source.f\00"
@_QQcl.2E = linkonce constant [1 x i8] c"."
@_QQcl.23 = linkonce constant [1 x i8] c"#"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i64, align 8
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.fce0759fc1936aa37475bd94083fd5ca, i32 7)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 8)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.fce0759fc1936aa37475bd94083fd5ca, i32 8)
  %6 = call i1 @_FortranAioInputAscii(ptr %5, ptr nonnull @_QFEs, i64 200000)
  %7 = call i32 @_FortranAioEndIoStatement(ptr %5)
  %8 = load i64, ptr %1, align 8, !tbaa !3
  %9 = icmp sgt i64 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge24

.lr.ph:                                           ; preds = %0, %.lr.ph
  %10 = phi i64 [ %16, %.lr.ph ], [ 1, %0 ]
  %.01318 = phi i64 [ %spec.select, %.lr.ph ], [ 0, %0 ]
  %11 = add nsw i64 %10, -1
  %12 = getelementptr [200000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %11
  %13 = call i32 @_FortranACharacterCompareScalar1(ptr %12, ptr nonnull @_QQcl.2E, i64 1, i64 1)
  %14 = icmp eq i32 %13, 0
  %15 = zext i1 %14 to i64
  %spec.select = add i64 %.01318, %15
  %16 = add nuw i64 %10, 1
  %exitcond.not = icmp eq i64 %10, %8
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  %.pre = load i64, ptr %1, align 8, !tbaa !3
  %17 = icmp sgt i64 %.pre, 0
  br i1 %17, label %.lr.ph23, label %._crit_edge24

.lr.ph23:                                         ; preds = %._crit_edge, %.lr.ph23
  %18 = phi i64 [ %27, %.lr.ph23 ], [ 1, %._crit_edge ]
  %.021 = phi i64 [ %26, %.lr.ph23 ], [ %spec.select, %._crit_edge ]
  %.220 = phi i64 [ %.3, %.lr.ph23 ], [ %spec.select, %._crit_edge ]
  %.01419 = phi i64 [ %.115, %.lr.ph23 ], [ 0, %._crit_edge ]
  %19 = add nsw i64 %18, -1
  %20 = getelementptr [200000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %19
  %21 = call i32 @_FortranACharacterCompareScalar1(ptr %20, ptr nonnull @_QQcl.23, i64 1, i64 1)
  %22 = icmp eq i32 %21, 0
  %23 = zext i1 %22 to i64
  %.115 = add i64 %.01419, %23
  %not. = xor i1 %22, true
  %24 = sext i1 %not. to i64
  %.3 = add i64 %.220, %24
  %25 = add i64 %.115, %.3
  %26 = call i64 @llvm.smin.i64(i64 %.021, i64 %25)
  %27 = add nuw i64 %18, 1
  %exitcond26.not = icmp eq i64 %18, %.pre
  br i1 %exitcond26.not, label %._crit_edge24, label %.lr.ph23

._crit_edge24:                                    ; preds = %.lr.ph23, %0, %._crit_edge
  %.0.lcssa = phi i64 [ %spec.select, %._crit_edge ], [ 0, %0 ], [ %26, %.lr.ph23 ]
  %28 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.fce0759fc1936aa37475bd94083fd5ca, i32 27)
  %29 = call i1 @_FortranAioOutputInteger64(ptr %28, i64 %.0.lcssa)
  %30 = call i32 @_FortranAioEndIoStatement(ptr %28)
  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 @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #0

attributes #0 = { 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"}
