Suppose I had once borrowed your boat and, secretly, replaced each board with a similar but different one. Then, later, when I brought it back, did I return your boat to you? What kind of question is that? It's really not about boats at all, but about what people mean by same. For same is never absolute but always a matter of degree. If I had merely changed one plank, we'd all agree that it's still your boat — but after all its parts are changed, we're not so sure of its identity. In any case, we do not doubt that the second boat will behave in much the same way — to the extent that all those substituted boards are suitably equivalent.
What has this to do with brains? Well, now suppose that we could replace each of your brain cells with a specially designed computer chip that performs the same functions, and then suppose that we interconnect these devices just as your brain cells are connected. If we put it in the same environment, this new machine would reproduce the same processes as those within your brain. Would that new machine be the same as you? Again, the real question is not what we mean by you, but what we mean by same. There isn't any reason to doubt that the substitute machine would think and feel the same kinds of thoughts and feelings that you do — since it embodies all the same processes and memories. Indeed, it would surely be disposed to declare, with all your own intensity, that it is you. Would that machine be right or wrong? As far as I can see, this, too, is merely a matter of words. A mind is a way in which each state gives rise to the state that follows it. If that new machine had a suitable body and were placed in a similar environment, its sequence of thoughts would be essentially the same as yours — since its mental states would be equivalent to yours.
Modifying or replacing the physical parts of a brain will not affect the mind it embodies, unless this alters the successions of states in that brain.
You might object to this idea about duplicating minds on the grounds that it would never be practical to duplicate enough details. You could argue the same about that borrowed boat: no matter how carefully a carpenter were to copy every board, there would always remain some differences. This plank would be a little too stiff, that one would be a little too weak, and no two of them would bend in exactly the same way. The copied boat would never be precisely the same — even though you might need a microscope to see the differences. For similar reasons, it would be impractical to duplicate, with absolute fidelity, all the interactions in a brain. For example, our brain cells are all immersed in a liquid that conducts electricity, which means that every cell has at least a small effect on every other cell. If we tried to imitate your brain with a network of computer chips, many of those tiny interactions would be left out.
Can you then boast that your duplicated brain-machine would not have the same mind as yours because its computer chips don't work exactly like the brain cells they purport to replace? No; you'd get more than you bargained for if you argued that the new machine was not the same as you, merely because of microscopic differences. Consider that as you age, you're never the same as a moment ago. If such small differences matter that much, this would prove that you yourself are not the same as you.