#include <bits/stdc++.h>   using namespace std;   long long power(long long base, long long pow, long long mo) {     long long res = 1;     while (pow) {       if (pow % 2 != 0) res = (res * base) % mo;       base = (base * base) % mo;       pow /= 2;     }     return res;   }   long long inv(long long i) { return power(i, 1000000007 - 2, 1000000007); }   std::string str =  All Good Till Here ;   void solve() {     long long i, j, x, n;     string str;     cin >> str;     long long up = 0, lr = 0, up1 = 0, lr1 = 0;     n = str.length();     for (long long i = 0; i < n; i++) {       if (str[i] >=  a  && str[i] <=  z )         lr++;       else         up++;     }     long long ans = INT_MAX;     for (long long i = 0; i < n; i++) {       ans = min(ans, lr1 + up - up1);       if (str[i] >=  a  && str[i] <=  z )         lr1++;       else         up1++;     }     ans = min(ans, lr1 + up - up1);     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long tt;     tt = 1;     while (tt--) {       solve();     }     return 0;   }   