#include <algorithm>
#include <bits/stdc++.h>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <iostream>
#include <iterator>
#include <stdexcept>
#include <type_traits>
#include <vector>

// lib/monoid.hpp
#ifndef MONOID_HPP
#define MONOID_HPP


namespace tools {
  template <typename T>
  class monoid {
  private:
    ::std::function<T(T, T)> m_operation;
    T m_identity;

  public:
    monoid(const ::std::function<T(T, T)>& operation, const T& identity) :
      m_operation(operation),
      m_identity(identity) {
    }
    monoid(const ::tools::monoid<T>&) = default;
    monoid(::tools::monoid<T>&&) = default;
    ::tools::monoid<T>& operator=(const ::tools::monoid<T>&) = default;
    ::tools::monoid<T>& operator=(::tools::monoid<T>&&) = default;
    virtual ~monoid() = default;

    const ::std::function<T(T, T)>& operation() const {
      return this->m_operation;
    }
    const T& identity() const {
      return this->m_identity;
    }
  };
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// lib/group.hpp
#ifndef GROUP_HPP
#define GROUP_HPP


namespace tools {
  template <typename T>
  class group : public ::tools::monoid<T> {
  private:
    ::std::function<T(T)> m_inverse;

  public:
    group(const ::std::function<T(T, T)>& operation, const T& identity, const ::std::function<T(T)>& inverse) :
      ::tools::monoid<T>(operation, identity), m_inverse(inverse) {
    }
    group(const ::tools::group<T>&) = default;
    group(::tools::group<T>&&) = default;
    ::tools::group<T>& operator=(const ::tools::group<T>&) = default;
    ::tools::group<T>& operator=(::tools::group<T>&&) = default;
    virtual ~group() = default;

    const ::std::function<T(T)>& inverse() const {
      return this->m_inverse;
    }

    template <typename U = T, typename ::std::enable_if<::std::is_integral<U>::value, ::std::nullptr_t>::type = nullptr>
    static ::tools::group<U> plus() {
      return ::tools::group<U>(::std::plus<U>(), 0, ::std::negate<U>());
    }
  };
}

#endif

// lib/cumsum.hpp
#ifndef CUMSUM_HPP
#define CUMSUM_HPP


/*
usage:

std::vector<std::vector<int>> a;
const auto cumsum = tools::cumsum2d(tools::group<int>::plus(), a.begin(), a.end());
cumsum(x1, y1, x2, y2);
*/

namespace tools {
  namespace detail {
    namespace cumsum {
      template <typename Iterator>
      class monoid1d {
      private:
        using T = typename ::std::iterator_traits<Iterator>::value_type;
        ::tools::monoid<T> monoid;
        ::std::vector<T> from_left;
        ::std::vector<T> from_right;

      public:
        monoid1d(const ::tools::monoid<T>& monoid, const Iterator& begin, const Iterator& end) :
          monoid(monoid), from_left({monoid.identity()}), from_right({monoid.identity()}) {
          ::std::vector<T> source;
          ::std::copy(begin, end, ::std::back_inserter(source));
          this->from_left.reserve(source.size() + 1);
          for (const T& source_i : source) {
            this->from_left.push_back(monoid.operation()(this->from_left.back(), source_i));
          }
          ::std::reverse(source.begin(), source.end());
          this->from_right.reserve(source.size() + 1);
          for (const T& source_i : source) {
            this->from_right.push_back(monoid.operation()(this->from_right.back(), source_i));
          }
          ::std::reverse(this->from_right.begin(), this->from_right.end());
        }

        T operator()(const ::std::size_t l, const ::std::size_t r) const {
          if (l == 0) {
            return this->from_left[r];
          } else if (r + 1 == this->from_right.size()) {
            return this->from_right[l];
          } else {
            throw ::std::runtime_error("Unsupported operation.");
          }
        }
      };

      template <typename Iterator>
      class group1d {
      private:
        using T = typename ::std::iterator_traits<Iterator>::value_type;
        ::tools::group<T> group;
        ::std::vector<T> preprocessed;

      public:
        group1d(const ::tools::group<T>& group, const Iterator& begin, const Iterator& end) :
          group(group), preprocessed({group.identity()}) {
          for (Iterator it = begin; it != end; ++it) {
            this->preprocessed.push_back(group.operation()(this->preprocessed.back(), *it));
          }
        }

        T operator()(const ::std::size_t l, const ::std::size_t r) const {
          return this->group.operation()(this->preprocessed[r], this->group.inverse()(this->preprocessed[l]));
        }
      };

      template <typename Iterator>
      class group2d {
      private:
        using OuterT = typename ::std::iterator_traits<Iterator>::value_type;
        using T = typename ::std::iterator_traits<typename OuterT::iterator>::value_type;
        ::tools::group<T> group;
        ::std::vector<::std::vector<T>> preprocessed;

      public:
        group2d(const ::tools::group<T>& group, const Iterator& begin, const Iterator& end) :
          group(group),
          preprocessed(
            ::std::distance(begin, end) + 1,
            ::std::vector<T>((begin == end ? 0 : ::std::distance(::std::begin(*begin), ::std::end(*begin))) + 1, group.identity())
          )
        {
          const ::std::size_t height = ::std::distance(begin, end);
          const ::std::size_t width = begin == end ? 0 : ::std::distance(::std::begin(*begin), ::std::end(*begin));

          {
            Iterator it1 = begin;
            for (::std::size_t y = 0; y < height; ++y, ++it1) {
              auto it2 = ::std::begin(*it1);
              for (::std::size_t x = 0; x < width; ++x, ++it2) {
                this->preprocessed[y + 1][x + 1] = group.operation()(this->preprocessed[y + 1][x], *it2);
              }
            }
          }
          for (::std::size_t x = 0; x < width; ++x) {
            for (::std::size_t y = 0; y < height; ++y) {
              this->preprocessed[y + 1][x + 1] = group.operation()(this->preprocessed[y][x + 1], this->preprocessed[y + 1][x + 1]);
            }
          }
        }

        T operator()(const ::std::size_t x1, const ::std::size_t y1, const ::std::size_t x2, const ::std::size_t y2) const {
          T tmp = this->group.operation()(this->preprocessed[x2][y2], this->group.inverse()(this->preprocessed[x1][y2]));
          tmp = this->group.operation()(tmp, this->group.inverse()(this->preprocessed[x2][y1]));
          return this->group.operation()(tmp, this->preprocessed[x1][y1]);
        }
      };
    }
  }

  template <typename Iterator>
  ::std::function<typename ::std::iterator_traits<Iterator>::value_type(::std::size_t, ::std::size_t)> cumsum1d(
    const ::tools::monoid<typename ::std::iterator_traits<Iterator>::value_type>& monoid,
    const Iterator& begin,
    const Iterator& end
  ) {
    return ::tools::detail::cumsum::monoid1d<Iterator>(monoid, begin, end);
  }

  template <typename Iterator>
  ::std::function<typename ::std::iterator_traits<Iterator>::value_type(::std::size_t, ::std::size_t)> cumsum1d(
    const ::tools::group<typename ::std::iterator_traits<Iterator>::value_type>& group,
    const Iterator& begin,
    const Iterator& end
  ) {
    return ::tools::detail::cumsum::group1d<Iterator>(group, begin, end);
  }

  template <typename Iterator>
  ::std::function<typename ::std::iterator_traits<Iterator>::value_type(::std::size_t, ::std::size_t, ::std::size_t, ::std::size_t)> cumsum2d(
    const ::tools::group<typename ::std::iterator_traits<Iterator>::value_type>& group,
    const Iterator& begin,
    const Iterator& end
  ) {
    return ::tools::detail::cumsum::group2d<Iterator>(group, begin, end);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::string S;
  std::cin >> N >> S;

  std::vector<std::pair<char, i64>> chunks;
  for (auto prev_it = S.end(), it = S.begin(); it != S.end(); prev_it = it++) {
    if (prev_it != S.end() && *prev_it == *it) {
      ++chunks.back().second;
    } else {
      chunks.push_back(std::make_pair(*it, 1));
    }
  }

  if (!chunks.empty() && chunks.front().first == '.') chunks.erase(chunks.begin());
  if (!chunks.empty() && chunks.back().first == '#') chunks.pop_back();

  const i64 paired_chunks_size = chunks.size() / 2;
  std::vector<i64> blacks;
  if (!chunks.empty()) {
    blacks.reserve(paired_chunks_size);
    for (auto it = chunks.begin(); it != chunks.end(); ++it, ++it) {
      blacks.push_back(it->second);
    }
  }
  std::vector<i64> whites;
  if (!chunks.empty()) {
    whites.reserve(paired_chunks_size);
    for (auto it = chunks.begin(); it != chunks.end(); ++it) {
      ++it;
      whites.push_back(it->second);
    }
  }

  const auto black_cumsum = tools::cumsum1d(tools::group<i64>::plus(), blacks.begin(), blacks.end());
  const auto white_cumsum = tools::cumsum1d(tools::group<i64>::plus(), whites.begin(), whites.end());
  i64 answer = std::numeric_limits<i64>::max();
  for (i64 i = 0; i <= paired_chunks_size; ++i) {
    answer = std::min(answer, black_cumsum(0, i) + white_cumsum(i, paired_chunks_size));
  }
  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 7408