#![allow(unused_parens)]
use std::error::Error;
use std::io;
use std::io::Read;
use std::iter;
use itertools::Itertools;

enum Char {
	Unchanged(iter::Once<char>),
	Lower(std::char::ToLowercase),
	Upper(std::char::ToUppercase)
}

impl Iterator for Char {
	type Item = char;
	fn next(&mut self) -> Option<Self::Item> {
		match self {
			Self::Unchanged(i) => i.next(),
			Self::Lower(i) => i.next(),
			Self::Upper(i) => i.next()
		}
	}
}

#[derive(Clone, Copy, PartialEq)]
enum AlphaCase {
	Upper,
	Lower
}

impl From<bool> for AlphaCase {
	fn from(b: bool) -> Self {
		match b {
			false => Self::Upper,
			true => Self::Lower
		}
	}
}

impl From<AlphaCase> for f64 {
	fn from(case: AlphaCase) -> Self {
		match case {
			AlphaCase::Upper => 0.8,
			AlphaCase::Lower => 0.2
		}
	}
}

impl AlphaCase {
	fn negate(&mut self) {
		*self = match self {
			Self::Upper => Self::Lower,
			Self::Lower => Self::Upper
		}
	}
}

fn process_char(c: char, prev: &mut AlphaCase, pprev: &mut AlphaCase, sum: &mut u32) -> Char {
	*sum = (*sum + c as u32) % 8;
	if(!c.is_alphabetic()) {
		return Char::Unchanged(iter::once(c));
	}
	if(prev == pprev) {
		*pprev = *prev;
		prev.negate();
		return match prev {
			AlphaCase::Upper => Char::Upper(c.to_uppercase()),
			AlphaCase::Lower => Char::Lower(c.to_lowercase())
		};
	}
	*pprev = *prev;
	if(*sum > 0) {
		 prev.negate()
	}
	match prev {
		AlphaCase::Upper => Char::Upper(c.to_uppercase()),
		AlphaCase::Lower => Char::Lower(c.to_lowercase())
	}
}

fn main() -> Result<(), Box<dyn Error>> {
	let mut sum = 0;
	let input = {
		let mut s = String::new();
		let mut stdin = io::stdin();
		stdin.read_to_string(&mut s)?;
		s
	};
	let mut prev = AlphaCase::Upper;
	let mut pprev = AlphaCase::Lower;
	for chunk in &input.chars().into_iter().chunks(65536) {
		print!("{}", chunk.map(|c| process_char(c, &mut prev, &mut pprev, &mut sum)).flatten().collect::<String>());
	}
	println!();
	Ok(())
}

