import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();  // 矩阵行数
        int m = sc.nextInt();  // 矩阵列数
        int k = sc.nextInt();  // 最多可染色的格子数
        char[][] matrix = new char[n][m];

        // 读取矩阵数据
        for (int i = 0; i < n; i++) {
            matrix[i] = sc.next().toCharArray();
        }

        List<Integer> blockLengths = new ArrayList<>();

        // 按列遍历,找出所有垂直连续的白色块(长度≥2)
        for (int j = 0; j < m; j++) {  // 遍历每一列
            int currentBlockLength = 0;  // 当前连续白色块的长度
            for (int i = 0; i < n; i++) {  // 遍历列中的每一行
                if (matrix[i][j] == 'o') {  // 遇到白色格子,增加块长度
                    currentBlockLength++;
                } else {  // 遇到非白色格子(黑色)
                    // 若当前块长度≥2,记录下来(只有≥2的块才能产生得分)
                    if (currentBlockLength >= 2) {
                        blockLengths.add(currentBlockLength);
                    }
                    currentBlockLength = 0;  // 重置块长度
                }
            }
            // 处理列末尾可能存在的连续白色块
            if (currentBlockLength >= 2) {
                blockLengths.add(currentBlockLength);
            }
        }

        // 按块长度从大到小排序(优先处理长块,能产生更多得分)
        Collections.sort(blockLengths, Collections.reverseOrder());

        int score = 0;
        // 遍历所有块,计算最大得分
        for (int length : blockLengths) {
            if (k == 0) break;  // 染色次数用尽,退出

            // 取当前块长度与剩余染色次数的较小值(最多染这么多格子)
            int cellsToDye = Math.min(k, length);

            // 只有染色数≥2时才能产生得分(连续2个格子产生1分,3个产生2分,以此类推)
            if (cellsToDye >= 2) {
                score += cellsToDye - 1;
            }

            k -= cellsToDye;  // 消耗染色次数
        }

        System.out.println(score);
    }
}